Labs/Jetpack/JEP/11: Difference between revisions

From MozillaWiki
< Labs‎ | Jetpack‎ | JEP
Jump to navigation Jump to search
(Origination)
 
(added more stuff)
Line 13: Line 13:
=== Introduction and Rationale ===
=== Introduction and Rationale ===


This JEP describes a simple mechanism through which Jetpacks can persistently store blobs of JSON data.
This JEP describes a simple mechanism through which Jetpacks can persistently store JS primitives and blobs of JSON data.


As part of this proposal is adding a <code>jetpack.storage</code> namespace.
As part of this proposal is adding a <code>jetpack.storage</code> namespace.
Line 19: Line 19:
=== Proposal ===
=== Proposal ===


Persistent storage will live at <code>jetpack.storage.json</code>. The <code>jetpack.storage</code> will provide access to any other available storage systems, such as sqlite.  The current <code>jetpack.sessionStorage</code> object, which allows arbitrary JS objects (they need not be JSON-able) to be stored between reloads of a Jetpack within the same Firefox session, will be renamed to <code>jetpack.storage.session</code>.
Persistent storage will live at <code>jetpack.storage.simple</code>. The <code>jetpack.storage</code> will provide access to any other available storage systems, such as sqlite.  The current <code>jetpack.sessionStorage</code> object, which allows arbitrary JS objects (they need not be JSON-able) to be stored between reloads of a Jetpack within the same Firefox session, will be renamed to <code>jetpack.storage.session</code>.


==== Setting the clipboard ====
==== Storing Values ====


<pre class="brush:js;toolbar:false;">
<pre class="brush:js;toolbar:false;">
jetpack.storage.json.set( key, value )
jetpack.storage.simple.set(key, value)
</pre>
</pre>


Line 36: Line 36:


This function has no return value.
This function has no return value.
==== Removing Values ====


<pre class="brush:js;toolbar:false;">
<pre class="brush:js;toolbar:false;">
jetpack.storage.json.remove( key )
jetpack.storage.simple.remove(key)
</pre>
</pre>


Line 50: Line 52:


This function has no return value.
This function has no return value.
'''Examples'''
An example of using the persistent storage is as follows:
<pre class="brush:js;">
TODO
</pre>

Revision as of 00:19, 28 May 2009

Draft-template-image.png THIS PAGE IS A WORKING DRAFT Pencil-emoji U270F-gray.png
The page may be difficult to navigate, and some information on its subject might be incomplete and/or evolving rapidly.
If you have any questions or ideas, please add them as a new topic on the discussion page.

JEP 11 - Simple Persistent Storage

  • Author: Atul Varma <atul at mozilla dot com>
  • Champion: Atul Varma <atul at mozilla dot com>
  • Status: Draft
  • Type: API Track
  • Created: 27 May 2009
  • Reference Implementation: None
  • JEP Index

Introduction and Rationale

This JEP describes a simple mechanism through which Jetpacks can persistently store JS primitives and blobs of JSON data.

As part of this proposal is adding a jetpack.storage namespace.

Proposal

Persistent storage will live at jetpack.storage.simple. The jetpack.storage will provide access to any other available storage systems, such as sqlite. The current jetpack.sessionStorage object, which allows arbitrary JS objects (they need not be JSON-able) to be stored between reloads of a Jetpack within the same Firefox session, will be renamed to jetpack.storage.session.

Storing Values

jetpack.storage.simple.set(key, value)

Arguments

key: A string uniquely identifying the data to be placed in persistent storage.

value: A JS primitive or JSON-able JS object that represents the data to be stored in persistent storage. If some other data with the given key is already being stored, it is overwritten by value.

Return value

This function has no return value.

Removing Values

jetpack.storage.simple.remove(key)

Removes the key and its associated data from persistent storage.

Arguments

key: The string uniquely identifying the data to be removed from persistent storage.

Return value

This function has no return value.