Local Storage helpers for Meteor with ReactiveVar and ReactiveDict.
Add the package to your project:
meteor add xerdi:local-storageThe package exports three classes which can be used similarly.
import {LocalStorage, LocalVarStorage, LocalDictStorage} from 'xerdi:local-storage';
const defaults = {
a: true,
b: 5,
c: 'text'
};
export const mySettings = new LocalDictStorage('mySettings', defaults);
Both LocalVarStorage and LocalDictStorage extend from LocalStorage.
constructorTakes a storage key and an object with default values.get()Gets the stored values.set(keyOrObject, value)Either gets an object for setting all values or a key and value to set.unset(key)Only works forLocalDictStorageand removes the given key from the dictionary.setDefault()Sets all values to their default value.clear()Wipes the stored data.