Loading…

Explain the difference between observables and promises in angular 2?

  Observable Promise
1. Used from the library RxJS.
import { Observable } from 'rxjs';
Built-in API.
2. Can show multiple values using setInterval() method Can resolve only one async task and cannot be used again
3. Can unsubscribe from the observables no longer needed. A promise cannot be canceled.
4. Lazy. Observable is called only when we subscribe. Not lazy.
5. Rich set of operators in the library like map, filter, pipe, retry, etc. No such additional features available

Suggest An Answer

No suggestions avaliable!

Latest post from Angular 2 Interview Questions

Ask Question