observe Method

Returns an observable that will emit value changes for a specific key

@param key: string
The key for which to observe value changes

@returns Observable<T>
An observable that will emit value changes for a specific key

API

observe(key: string): Observable<T>;

Example

class ExampleSource<T = any> implements KeyValueSource<T> {
  private readonly subject = new Subject<string>();
  
  observe(key: string): Observable<T> {
    return this.subject.pipe(
      filter(eKey => key === eKey),
      map(key => this.get(key)),
    );
  }
  
  // ...
}