cesarve:persistent-reactive-var

v0.1.0Published 8 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

Reactive local storage between tabs

Install

$ meteor add cesarve:persistent-reactive-var

Usage

1
2/***
3* create new var
4* take to params
5* uniqueId required: an unique string foe each new persistent var
6* defaultValue: a initial value if the storage var does not exist (no accept functions)
7*/
8foo= new PersistentReactiveVar(uniqueId: String,defaultValue: Any)
9// example foo=PersistentReactiveVar('MyUniqueString',{a:1})
10
11
12/***
13* set value
14* take 2 params
15* value
16* expire in milliseconds or null for no expire 
17*/
18foo.set({foo:'bar'},expire)
19// example foo=set({a:2},1000*60*60*24)
20
21/***
22* get storaged value
23* take no params
24* return Any value
25*/
26foo.get()
27
28/***
29* set an initial value
30* take one param
31* val Any value
32*/
33foo.setDefault(val) 
34
35//clear var
36foo.set(undefined)

Very simple api, tiny footprint just (use amplify behind the scene)

Licence MIT