0

I want to make dynamic REST client in Angular that would be able to detect changes in a remote repository and subsequently update data.

I saw implementation of this in few examples, but they put all refetch logic in components. Is this the correct approach? If fetched data is spread across multiple components that would require lot of boilerplate code (or maybe inheritance of some kind?)

How to put logic of refetching into service (any examples of how to do it correctly and with style)?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • 1
    Those components can all get the data from the same shared service, that's no different. If you want to have a stream that emits periodically to trigger a new fetch, see [`Observable.timer`](https://www.learnrxjs.io/operators/creation/timer.html). – jonrsharpe Mar 27 '18 at 16:35
  • see this https://stackoverflow.com/questions/38521471/three-way-binding-in-angular-2-and-angularfire2 – Vikas Mar 27 '18 at 16:45
  • if you have control over the remote repo, why not implement a socket and push the data to the client as and when it changes – Obed Amoasi Mar 27 '18 at 17:06

0 Answers0