Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could identify() also read from localStorage? #71

Open
georgecrawford opened this issue Mar 9, 2018 · 4 comments
Open

Could identify() also read from localStorage? #71

georgecrawford opened this issue Mar 9, 2018 · 4 comments

Comments

@georgecrawford
Copy link

Hi there,

Firstly, thanks for this great service. It's working fantastically well for us.

We have an application which involves a fair bit of user state changing - logging in and out, setting different properties, etc. For each of these changes, we want to identify(user) to get the appropriate feature flags. I'm already bootstrapping from localStorage during initialize(), and I can's see a good reason why the identify() function doesn't also make use of this cache. I'd be happy if identify() used the last-known values from localStorage, whilst in the background loading the fresh values from the network, populating localStorage, and perhaps firing the change event if there's an update.

Could this work? I may well have missed something really obvious, so apologies!

@eli-darkly
Copy link
Contributor

Thanks! That looks reasonable at first glance, and we're going to look into it further.

@georgecrawford
Copy link
Author

Thanks Eli. One thought which occurred to me is that I might want to bootstrap the initialize with a JSON object, but for identify to cache in localStorage. So it might be good to separate these two flags, rather than assume that the user wants localStorage backing for both.

eli-darkly added a commit that referenced this issue May 22, 2018
don't do exact match on JSON content type
@threehams
Copy link

localStorage is unavailable (with thrown errors!) from Safari private browsing mode, so safety or a fallback of some kind would be needed.

@eli-darkly
Copy link
Contributor

@threehams We already have logic that deals with the possibility of localStorage being unavailable or throwing errors.

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

No branches or pull requests

4 participants