Web / Angular Interview questions
Difference between Promises and Observable.
| Promise. | Observable. |
| A Promise handles only one event when an async operation completes or fails. | An Observable is like a Stream and accepts 0 or more (multiple) events where the callback is called for each event. |
| Promise doesn't support cancelation. | Observables are cancelable. |
| Promises execute immediately on creation. | Observables are declarative and computation does not start until subscription. |
| Promises provide only one value. | Observables provide many values. |
| Promises push errors to the child promises for error handling. | Observables subscribe() is responsible for handling errors that provides centralized and predictable error handling. |
More Related questions...