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

LocalStorage not working with static variable #61

Open
Havock94 opened this issue Sep 26, 2018 · 2 comments
Open

LocalStorage not working with static variable #61

Havock94 opened this issue Sep 26, 2018 · 2 comments

Comments

@Havock94
Copy link

Hello.
I'm using ngx-store in a class with static variables

@LocalStorage('hsky') private static husky: string = null;

but if I set the variable with

... this.husky = 'Hey!'; ...

the value in the local storage only changes the first time it is set, every other assignment doesn't work.

The LocalStorageService.set method correctly update the local storage value though.

(new LocalStorageService()).set('hsky', 'Hey hey!');

@Havock94
Copy link
Author

Havock94 commented Sep 26, 2018

And actually having an init function that sets the default value makes the assignment work as well

public static init(){
    this.husky = "";
}
...
this.husky = 'Hey!';  //This works!
...

@DanielKucal
Copy link
Member

Static fields are not supported for now. From what I can remember, it'd need additional decorator on the class... I'd recommend you to just use a regular singleton service.

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

2 participants