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 -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -