marcuswestin / store.js

Cross-browser storage for all use cases, used across the web.
MIT License
14.01k stars 1.33k forks source link

clearAll() per namespace? #300

Open bblimke opened 5 years ago

bblimke commented 5 years ago

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
nbubna commented 5 years ago

Why not just use clear()

bblimke commented 5 years ago

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

bblimke commented 5 years ago

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

nbubna commented 5 years ago

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.