1

I have my full code in below stackblitz link,

https://stackblitz.com/edit/angular-simple-cache-service-with-rxjs-8cywbi?file=app%2Fapp.component.ts

Here I am trying to update the UI when someone updates the storagelocation(in this case a Map - which is in cache.service.ts file).

  • When I click Get method, it get the value from cache and update the UI.
  • When I click Set method, it update value in a Map inside CacheService.

Is there any way to update the UI automatically when I call Set using RxJs ?

Note:You can see my new trails in cache.service2.ts file.

Sreekumar P
  • 5,900
  • 11
  • 57
  • 82
  • 1
    Inside setValue, if you just do this.loadMore$.next(key);it will update your component. Or, make inFlightObservables property in cacheService public and subscribe to that inside your component. Not sure if this is what you meant. – Jinto Feb 08 '18 at 10:33
  • @jintoppy: this.loadMore$.next(key) will update the UI but with new row. I want to update the existing rows that are already binded in UI. Eg. Assume I clicked "Get 100" once, then one row will be displayed, after that when I click "Set 100", I want to update the 1st row with the new data. – Sreekumar P Feb 08 '18 at 10:44
  • That you can achieve by adding a check inside scan. https://stackblitz.com/edit/angular-simple-cache-service-with-rxjs-gm4gxo?file=app/app.component.ts – Jinto Feb 08 '18 at 12:15

0 Answers0