This might be the silly one but help me out with the question. I started learning RxJs but I could see RxJs is used for reactive programming where we can subscribe to events and handling multiple events and process in chaining with observables and I got the doubt like what will be the difference between using async/await or promises in javascript because they are also doing the async flow in javascript. Any advantages over async/await.
-
http://reactivex.io/intro.html – martin Jul 25 '19 at 07:29
-
Possible duplicate of [What is the difference between Promises and Observables?](https://stackoverflow.com/questions/37364973/what-is-the-difference-between-promises-and-observables) – frido Jul 25 '19 at 08:27
2 Answers
I suggest you search the web a bit as this will give you a much better answer and views on the difference between asynchronous promise and observable objects
The main difference is that you use promise when you want the code to be done asynchronously and you use observables when you want to be notify when a variable value is being altered (you observe the variable by subscribing to its events)

- 123
- 1
- 8
The main difference: Promise
is one-time while Observable
is assumed to emit for multiple times.
Events, HTTP streams, interval timers - that all does not fit Promise
well. So Observable
is more like generators than Promise
.
Say we need throttling click with requesting server having some short timeout in case server does not respond in 5 seconds. We can either use event handler wrapped into throttle
and then running Promise-based fetch
with attaching promisified timeout with Promise.race()
.
Or we can use only rxjs
to describe complete flow as set of operators.

- 22,209
- 7
- 57
- 64