diff options
Diffstat (limited to 'lib/stores.js')
-rw-r--r-- | lib/stores.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/stores.js b/lib/stores.js new file mode 100644 index 0000000..eacb5e2 --- /dev/null +++ b/lib/stores.js @@ -0,0 +1,12 @@ +export function set(store, value) { + window.stores[store] = value + Object.values(window.storesEvents).forEach(ev => {if(ev.store == store) cb()}) +} +export function update(store) { + Object.values(window.storesEvents).forEach(ev => {if(ev.store == store) cb()}) +} +export function onChange(store, cb) { + let id = nextStoresEventID++; + storesEvents[id] = {store, cb}; + return id; +} \ No newline at end of file |