Skip to content
This repository was archived by the owner on Mar 8, 2021. It is now read-only.
This repository was archived by the owner on Mar 8, 2021. It is now read-only.

[Feature Request] Add where method to find value location #20

Description

@aaronmallen

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions