Skip to content

Add Observable for Set Events #89

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

Closed
iamwyza opened this issue Mar 12, 2019 · 2 comments
Closed

Add Observable for Set Events #89

iamwyza opened this issue Mar 12, 2019 · 2 comments
Assignees

Comments

@iamwyza
Copy link

iamwyza commented Mar 12, 2019

It would be nice to be able to have an observable that listens to all Set Events such that if I call this.localstorage.set("mykey", value); in class X, I could then have a subscriber in class Y that hears that the value in the DB has been updated/set.

class WidgetThing {
    constructor(private readonly localStorage: LocalStorage) {}
    public SetData() {
       this.localStorage.Set("MyKey", "some random data").subscribe();
    }
}

class SomeOtherClass {
   constructor(private readonly localStorage: LocalStorage) {
       this.localStorage.Events<T>("MyKey").subscribe((data: T, event: string) =>{
           console.log("something happened to MyKey!, it was " + event);
       });
   }
}
@cyrilletuzi
Copy link
Owner

Thanks for your interest in the lib. As stated in the README:

When reading data, you'll only get one value: the observable is here for asynchronicity but is not meant to emit again when the stored data is changed. And it's normal: if app data change, it's the role of your app to keep track of it, not of this lib. See #16 for more context and #4 for an example.

I'll keep this issue opened as, since the other ones, I've had some thinking, and maybe it would be possible to do this without being too out of the scope of the lib.

But I currently have no time for new features (upcoming v8 is already a lot of work). So 3 possibilities:

  • wait, with no guarantees,
  • do a PR (after having agreed on API design),
  • see if your company would be OK to finance this so I can include it in my work time.

@cyrilletuzi cyrilletuzi mentioned this issue Apr 24, 2019
4 tasks
@cyrilletuzi cyrilletuzi added this to the v8.0 milestone Apr 24, 2019
@cyrilletuzi cyrilletuzi self-assigned this Apr 24, 2019
@cyrilletuzi cyrilletuzi modified the milestones: v8.0, v8.1 May 17, 2019
@cyrilletuzi
Copy link
Owner

Available in 9.0.0-beta.2.

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