Holds an in-memory structure with potentially thousands of items. Relies on PrefixTree for storing this structure to remoteStorage.
SyncedMap | Holds an in-memory structure with potentially thousands of items. |
Functions | |
get | Retrieve one of the items from the in-memory store. |
set | Store an item into the in-memory store, under a key that identifies it uniquely. |
remove | Remove an item from the in-memory store, from under a key that identifies it uniquely. |
getKeys | Returns the keys of all items currently loaded into the in-memory store. |
load | Load the data into memory after a page refresh. |
get: function( key )
Retrieve one of the items from the in-memory store. Make sure to call load before calling this function.
key | string, the identifier of the item to be retrieved. Should not contain slashes. |
The current value of the item identified by <key>, or undefined if the item doesn’t exist. Will also return undefined if the item was not loaded yet.
load: function( key )
Load the data into memory after a page refresh. When the user connects their storage, data will come in and will be loaded automatically. Also, data that was stored into the SyncedMap since the last page refresh will stay loaded automatically. The only situation where the memory is flushed and you need to call SyncedMap.load, is when the user refreshes the page, or closes and reopens the tab, closes and reopens the browser, or turns the device off and on again.
A promise that fulfills when all items have been loaded from IndexedDB, through the BaseClient and the PrefixTree, into the SyncedMap (and therefore into memory).
Retrieve one of the items from the in-memory store.
get: function( key )
Store an item into the in-memory store, under a key that identifies it uniquely.
set: function( key, val )
Remove an item from the in-memory store, from under a key that identifies it uniquely.
remove: function( key )
Returns the keys of all items currently loaded into the in-memory store.
getKeys: function()
Load the data into memory after a page refresh.
load: function( key )