Is there a way for an angular application to access data that are outside of its app context(say in a javascript file normally imported) and detect all the changes that occur(again externally) in order to rerender and update its context?
2 Answers
Yea, which is what observables and subscriptions are for.
Multicasting observables and unicasting observables like behaviour subject would take care of that. For an instance assuming you are creating a notification service where you want to be listening for incoming notification, you can subscribe to it and when there is a new data it is detected automatically and you are tunned to it. when you wan to leave the page you then unsubscibe from it.

- 50,140
- 28
- 121
- 140

- 191
- 7
-
Actually, I didn't quite catch it, should I have to observe the global window object? – Andy Jul 23 '19 at 15:00
Rxjs is definitely in Angular learning curve and worth it to take time to research if you are planning to learn to enhance your Angular knowledege. It should help you with all kind of async, observe and a lot more works with ease.
I have answered a question of that which OP is asking how to fetching data in real time with Firebase
, you could take a look at that.
Addittionally, there is an answer that i think will get you a bigger scene of what capable of Observable from backend side compare to NodeJs streams which both have the capable of watching change from the sever then notify to your Angular app.

- 2,911
- 9
- 25
-
Yes, I would definitely learn more about the Angular world. Do you have any working example for it? – Andy Jul 23 '19 at 14:54