Labs/Jetpack/JEP/11: Difference between revisions

m
(Removed async API, replace with the new sync API - see bug 503466)
m (→‎Proposal: wording)
Line 25: Line 25:
Simple, persistent storage will live at <code>jetpack.storage.simple</code>. The <code>jetpack.storage</code> namespace will provide access to any other available storage systems, such as SQLite, secure/password storage, and so on.  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>.
Simple, persistent storage will live at <code>jetpack.storage.simple</code>. The <code>jetpack.storage</code> namespace will provide access to any other available storage systems, such as SQLite, secure/password storage, and so on.  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>.


Simple storage is really simple.  <code>jetpack.storage.simple</code> is a single, persistent JavaScript object available to each Jetpack feature.  For the most part this object is like any other JavaScript object, and a feature can set whatever properties it wants on it.  To manipulate its persistent data, a feature therefore need only use the various [https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference standard JavaScript functions and operators].  Each feature gets its own, private storage.
Simple storage is really simple.  <code>jetpack.storage.simple</code> is a single, persistent JavaScript object available and private to each Jetpack feature.  For the most part this object is like any other JavaScript object, and a feature can set whatever properties it wants on it.  To manipulate its persistent data, a feature therefore need only use the various [https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference standard JavaScript functions and operators].


The <code>jetpack.simple.storage</code> object is automatically flushed to disk. How and when it is flushed is an implementation detail -- either periodically and on onload or, perhaps in the future if using catch-alls, when a property is set on the object.  Storage may be flushed manually, however, by calling <code>jetpack.storage.simple.sync()</code>.  The object can be forced to reload its data from disk by calling <code>jetpack.storage.simple.open()</code>, although the data comes loaded automatically.
The <code>jetpack.simple.storage</code> object is automatically flushed to disk. How and when it is flushed is an implementation detail -- either periodically and on onload or, perhaps in the future if using catch-alls, when a property is set on the object.  Storage may be flushed manually, however, by calling <code>jetpack.storage.simple.sync()</code>.  The object can be forced to reload its data from disk by calling <code>jetpack.storage.simple.open()</code>, although the data comes loaded automatically.
Confirmed users
764

edits