javascript - rxjs Observable publishReplay new data -


i'm trying cache user data rxjs , works charm

protected users$ = observable.defer(() => this.getusersuncached())     .publishreplay(1, 5000)     .refcount()     .take(1);  public getusers(): observable<user[]> {     this.users$.sharereplay()     return this.users$; }  public getusersuncached(): observable<user[]> {     return this.api.get('/user')         .map((response) => response.json().data)         .catch(this.handleerror); } 

if call getusers cached userdata 5 seconds, , if call getusersuncached data uncached api

what super neat if call getuseruncached reset timer of cache , update it's content. i'm asking there clean method or should build own timer & behaviorsubject?


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -