-
-
Notifications
You must be signed in to change notification settings - Fork 69
Change event? #4
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
Comments
Can you provide a use case ? Local storage won't change by itself, so if you want to listen storage modifications, you should create an observable in your own app. For example : import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { AsyncLocalStorage } from 'angular-async-local-storage';
@Injectable()
export class SomeService {
public storageStream = new BehaviorSubject({});
public constructor(protected localStorage: AsyncLocalStorage) {}
public save(key: string, value: any) {
this.localStorage.setItem(key, value).subscribe(() => {
this.storageStream.next({ key, value });
});
}
} (It's just a quick example, BehaviorSubject may not be the best RxJS class for this case, and operations surely could be more linear.) |
Closing, as no use case was provided. |
Sorry if i up this issue,but i didn't understand very well how to listen changes to localstorage updates; (EXAMPLE);i have a class that read object from localstorage,and a service that update local storage when needed (example when there are new content to download). myclass:
My service (StorageService): ..
How i can update myClass.liveCategories when localStorage.liveCategories is changed? Sorry for the boring question,but i'm a little bit "new" to rjxs programming. |
Is there a way to make the observable of getItem() listen, if a local storage item has changed? E.g. after setItem().
The text was updated successfully, but these errors were encountered: