I was learning observables and found out that it is best to be used when we deal with the stream of data. But what can the examples of stream of data that we get from server, that is, primarily we send request to server to get some data then that data is sent to a client and we render. Well, is it true that by the stream of data it means that when we use web sockets and data is constantly sent to the client and this is where observables shines. Right? if so, what other examples can be the reason to use observables?
Asked
Active
Viewed 39 times
0
-
You may want to take a look at [this](https://medium.com/better-programming/rxjs-patterns-emerging-from-stackoverflow-asynchronous-api-calls-as-streams-in-the-real-world-ef636c9af19a) to see examples of use of Observables with http calls. This is also a [good answer](https://stackoverflow.com/a/50496692/5699993) to your question – Picci Mar 31 '20 at 09:11
1 Answers
0
In my experience, you have to try to use observables most of the time. Think of your code as a declaration of a graph of streams. Typically, you have a few sources of data (http, user clicks, forms validation...). Your app has the responsability to combine and transform these streams with rxjs. Then you subscribe only when needed to those observable (in your html for example). When everything is asynchronous like that, you will have a lot less errors and the code will be far more maintainable. Tell me if i'm not clear.

Oscar Guérin
- 76
- 5