store.js icon indicating copy to clipboard operation
store.js copied to clipboard

clearAll() per namespace?

Open bblimke opened this issue 6 years ago • 4 comments

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

bblimke avatar Jun 07 '19 12:06 bblimke

Why not just use clear()

nbubna avatar Jun 07 '19 16:06 nbubna

@nbubna Thank you! I didn't know about clear 👍

bblimke avatar Jun 07 '19 18:06 bblimke

@nbubna I get ns1.clear is not a function. Am I using outdated version?

bblimke avatar Jun 07 '19 18:06 bblimke

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.

nbubna avatar Jun 07 '19 18:06 nbubna