Open aaronmallen opened 9 years ago
In addition to that you could also add a locker.where()
method that would return the storage that object currently lives in.
locker.where('user')
// response: ['local']
var user = foo
var _user = {name: 'bar', prop: 'foo'}
locker.driver('local').put('user', user)
locker.driver('session').put('user', _user)
locker.where(foo)
// response: ['local']
locker.where({name: 'bar', prop:'foo'})
// response: ['session']
locker.driver('local').put('user', user)
locker.driver('session').put('user', user)
locker.where('user')
// response: ['local', 'session']
Interesting idea.. I can see how this would be useful. I will see if I can throw something together
Thanks
+1
querying objects in locker should query both session, and local unless specified. If I say
locker.has('user')
I would expect that to return true if there is an object called 'user' in either the local or session storage.Example use case:
Here I allow the user to define which locker they use. Specifying driver on
locker.put
makes sense, but now later through out my application I either need to create a $rootScope variable to tell me which locker to use or I need to do this all over the place:Ideally both
locker.has
andlocker.get
would query both lockers, unless I specifically saylocker.driver('local').has
orlocker.driver('local').get