Giter Club home page Giter Club logo

angular-locker's People

Contributors

admwx7 avatar danilo-valente avatar foxdavidj avatar johannesodland avatar niemyjski avatar robinbullocks4rb avatar seanclowdy avatar simison avatar tymondesigns avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-locker's Issues

Feature request: locker.getDriverName()

Hi.

I just added my own custom driver that uses cookies for storage, and works fine for the most part. Some functionality in my app needs just a bit more space than cookies can handle, so I want to disable that functionality when user's using a browser that does not support localStorage, like Safari in private mode.

To keep from having to test everywhere if localStorage is available and / or manually set the proper driver, I chucked it all in my Locker extension:

app.config(['CookieStorageProvider', 'lockerProvider',
  function (CookieStorageProvider, lockerProvider) {
    var defaults = {
      driver: 'local',
      namespace: 'my.namespace',
      separator: '_',
      eventsEnabled: true,
      extend: {}
    };

    try {
      localStorage.setItem('localStorageTest', 'localStorageTest');
      localStorage.removeItem('localStorageTest');
      lockerProvider.defaults(defaults);
    } catch(e) {
      defaults.extend = {
        cookieStorage: CookieStorageProvider.get()
      };

      defaults.driver = 'cookieStorage';
      lockerProvider.defaults(defaults);
    }
  }
]);

I haven't quite figured out if Locker is meant to use whatever driver(s) are available, and switch between them, leaving it unnecessary and undesirable for developers to even know what happens behind the curtains other than setting desired driver (default). If so, this might not be the right approach, and the feature request redundant. If Locker, on the other hand, is supposed to use one driver at the time (unless explicitly switched), then it would be nice to be able to call something like locker.getDriverName(), that would return 'cookieStorage' in the case of Safari private mode etc. in my case.

I'm using the "private" locker._options.driver attribute to achieve this right now, but that's hardly the intention.

๐Ÿ‘ Good or ๐Ÿ‘Ž garbage?

locker.put null values

When I do locker.put('key', null) it does not store the value properly. Is this intended using locker? localStorage takes the value just fine.

Safari Private Browsing

We need to be able to support Safari private browsing in our project but if the storage isn't supported, the browser just throws a JS exception and our angular app doesn't initialize. I've noticed the use of Remy's Polyfill but is this just a plug and play script? How exactly am I supposed to use this in a project?

Currently we fallback to $cookies using locker.isSupported() but I don't understand the point of this function if I can't call or check it?

LocalStorage gets reset on window.history.back()

I am storing some data in localStorage, but after calling window.history.back(), the data gets reset, for page refresh it works fine. How do deal with window.history.back() scenario.

Thanks in advance.

lockerProvider throws error when trying to setDefaultDriver

I tried to use lockerProvider, but it seems like it's not working as documented:

.config(['lockerProvider', function config(lockerProvider) {
lockerProvider.setDefaultDriver('session')
.setDefaultNamespace('myAppName')
.setSeparator('.')
.setEventsEnabled(false);
}]);

I tried to search for the configuration in the source code, I don't see any of them. Is this still supported?

How to save info in each tab in the same browser

The version is angular-locker "2.0.4".

If I put the value in storage " locker.driver('local')", the value will always be saved even I close the browser.

But If I used "locker.driver('session')" to save value, The value won't be get in another tab.

Could yo please give me some suggesion?

Thank you.

locker bind to scope doesnt work as expected

.config(function (lockerProvider) {
  lockerProvider
      .setDefaultDriver('local')
      .setEventsEnabled(true)
})

.run(function ($rootScope, locker) {
   locker.bind($rootScope, 'session')
})

I expected that to mean "root scope and local storage are always in sync for session key even across browser tabs", but it actually meant "setting root scope session also sets local storage session".

Firebase for example initializes values and updates them when things change (https://www.firebase.com/docs/web/libraries/angular/api.html#angularfire-firebaseobject-bindtoscope-varname).

Webpack

angular is undefined when using Webpack and ES6 syntax

Uncaught TypeError: Cannot read property 'module' of undefined

That error is thrown at this line

angular.module('angular-locker', [])

Example setup..

import angular from 'angular';
import 'angular-locker';

let appModule = angular.module('app', [
'ui.router',
'angular-locker'
])

Doc should encourage minification-friendly practice

.factory('MyFactory', function MyFactory(locker) {
locker.put('someKey', 'someVal');
});

should be :

.factory('MyFactory', ['locker', function MyFactory(locker) {
locker.put('someKey', 'someVal');
}]);

README out of date

in 7e0393d you removed the helper methods to set defaults in the provider but the documention in the README still indicates they can be used. If I get time this week I'll put in a pull request if no one has already.

Problem when trying to put or access multiple 'session' object.

Hi,

I've got a weird issue while trying to set multiple session values using the latest release (2.0.1). My default driver option is 'local'.

So if I do the following:

locker.driver('session').put('sessionKey1', 1);
locker.driver('session').put('sessionKey2', 2);
locker.driver('local').put('localKey1', 1);
locker.driver('local').put('localKey2', 2);

"sessionKey1" is set as a SessionStorage, but all three others are set as LocalStorage. The problem here is that "sessionKey2" should have been a SessionStorage not LocalStorage.

But if I change the order like this:

locker.driver('session').put('sessionKey1', 1);
locker.driver('local').put('localKey1', 1);
locker.driver('session').put('sessionKey2', 2);
locker.driver('local').put('localKey2', 2);

Everything work as expected.

Documentation Request - 100% Angular Fallback

In the midst of supporting private browsing on Safari (it doesn't allow webstorage), our product owner wanted a fallback for storage.

The solution we've provided was a temporary storage fallback, utilizing Angular's $cacheFactory and a decorator for angular-locker.

Here is a link to the Gist.

Would this be something you would want to provide in the case someone did not want to use Remy's polfill that utilizes cookies for a fallback? I realize that this is not as permanent as a cookie (refreshing will wipe the $cacheFactory values), but some people might want something Angular driven.

This is just a suggestion, any thoughts, comments, or criticisms would be highly appreciated as this is a code that is live on a production level website (tens of thousands of users a day).

Update bower and npm packages

It seems although we updated the bower package, it's not being picked up. I'm not sure if you need to run a bower command to reregister the package..

Plans to add TTL or other expiration concept?

Are there any plans to add TTL features? jStorage, for example, has a TTL feature that's pretty useful. I'd make a pull request but, to be honest, not too confident in my ability to implement it cleanly

Unable to implement both Local and Session in same project

First off, great library and I would love to use it. The only problem is that I am using both Local and Session Storage in my project. I don't see a way to implement both using the instructions in the README and nothing is coming to mind for an easy way to do it.

Is there an easy way to do this that I am missing?

Force invalidation of one item

Sorry, I've opened the issue in the wrong project...

Anyway, nice job. I'm using locker for some weeks and I haven't found any issues.
I'm looking for some way to invalidate a cache key, that is actually stored in locker, and return the refreshed value, not just a promise.
Sorry for the confusion, and thanks for your great work!

clean() does not work on 'session' driver and namespace with a dot

I am using clean() to remove all values from a given namespace. However, if the namespace contains a dot within it's name (e.g. 'test.namespace'), on my Chrome the namespace is not cleared of its values afterwards.

The following test case should demonstrate the problem:

locker.driver('session').namespace('test.namespace').put('test', 'testvalue'); locker.driver('session').namespace('test.namespace').clean();

In Chrome, the resource view for the session storage returns the following afterwards:
'test.namespace.test' => 'testvalue'

Could it be that the dotted namespace screws up the cleaning algorithm?

The version used is 2.0.4

[Feature Request] Add where method to find value location

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

Why the value in storage after I close the browser

The version is angular-locker "2.0.4".
I put the value in storage, for example:

var storage = locker.driver('local');
storage.put('user', user);

After I close the browser and reopen, input the url to enter in page, I found the value is still in storage.
storage.has('user') == true

Could you please tell me how to set the configuration to make the value clear after I close the browser?

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.