[Feature Request] Add where method to find value location
#20 geöffnet am 24. Juni 2015
Repository-Metriken
- Stars
- (313 Stars)
- PR-Merge-Metriken
- (PR-Metriken ausstehend)
Beschreibung
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:
app.controller('LoginCtrl', [
'$scope', 'locker', function($scope, locker) {
$scope.email = '';
$scope.password = '';
$scope.rememberMe = false;
$scope.signIn = void 0;
$scope.user = {
email: '',
password: ''
};
$scope.rememberMe = false;
return $scope.signIn = function() {
if ($scope.rememberMe) {
return locker.driver('local').put('user', $scope.user);
} else {
return locker.driver('session').put('user', $scope.user);
}
};
}
]);
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:
if (locker.driver('local').has('user')) {
return locker.driver('local').get('user');
} else {
return locker.get('user');
}
Ideally both locker.has and locker.get would query both lockers, unless I specifically say locker.driver('local').has or locker.driver('local').get