Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (7k points)

What is the difference between observables and promises in JavaScript frameworks like Angular?

1 Answer

0 votes
by (13.1k points)

A promise resolves to a single value asynchronously and observable limits to multiple values asynchronously.

Examples:

Promise: Response from an Ajax call

Observable: Click events

An observable allows you to treat streams of asynchronous events with the same sort of simple, composable operations that you use for the collections of data items

A promise is a single value and observable is like a function that can be invoked to produce multiple values. A promise is always cached and multicast whereas an observable is unicast.

Want to be a full stack developer? Check out the full stack developer course from Intellipaat.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...