What is the difference between Promise
and Observable
in Angular?
An example on each would be helpful in understanding both the cases. In w
Something I ran into that wasn't apparent from a first reading of the tutorial and docs was the idea of multicasting.
Make sure you're aware that by default, multiple subscriptions will trigger multiple executions in an Observable. Multiple subscriptions to a single HTTP call Observable will trigger multiple identical HTTP calls unless you .share()
(enable multicasting).
A promise forces you to deal with one thing at a time, unwrap its data, handle exceptions, has language support for cool things like async/await, and is pretty barebones otherwise.
An Observable has lots of bells and whistles, but you need to understand the power you're working with or it can be misused.