Question - What are the advantages of RXJS Observables over RxJS Promises?
Answer -
In RxJS, an Observable has many advantages over Promises. The following list shows some of them:
- An observable is like a Stream. It is used to pass zero or more events where the callback is called for each event.
- Observable is always preferred over Promise because it provides all the features of Promise and more.
- By using an observable, we can handle single or multiple events.
- Observables are cancelable, so this is also an advantage over Promises.
- Observable allows lazy initialization.
- Observable allows formatting data.
- Observable provides operators like map, forEach, reduce etc.