0.0.4 • Published 3 years ago

rx-smart-subscribe v0.0.4

Weekly downloads
-
License
-
Repository
-
Last release
3 years ago

RxSmartSubscribe

Simple class to help prevent subscribing to an observable more than once.

Usage

Use in your DI class to act as a cache

In this example, this.$http.get(...) will only ever be subscribed to once, yet getStaticOptions() will always return an observable with the response, even if getStaticOptions() is subscribed to many times in quick succession.

class SomeSingleton {
  private readonly cache = new SmartSubscribe(this.$http.get(...));

  public getStaticOptions() {
    return this.cache.go();
  }
}

Or if you don't know the exact source on instantiation

class SomeSingleton {
  private readonly cache = new SmartSubscribe();

  public getStaticOptions(arg: string) {
    this.cache.init(this.$http.get(arg));
    return this.cache.go();
  }
}
0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago