store.js
store.js copied to clipboard
clearAll() per namespace?
Is there a way to clear store for only one namespace?
When I create multiple stores with different namespaces and I call clearAll on any of them, it clears the data from all the stores.
var ns1 = store.namespace('ns1')
var ns2 = store.namespace('ns2')
ns1.set('foo', 'bar1')
ns2.set('foo', 'bar2')
ns1.get('foo') == 'bar1'
ns2.get('foo') == 'bar2'
ns1.clearAll()
ns1.get('foo') //undefined
ns2.get('foo') //undefined
Why not just use clear()
@nbubna Thank you! I didn't know about clear 👍
@nbubna I get ns1.clear is not a function. Am I using outdated version?
Oops. Sorry, i didn't have my caffeine this morning. I thought this was a bug on my store2 library, not Marcus' lib. Eeek. Major fail. Sorry.