Observables vs Promise in Angular

Promise in angular
Observable in angular
const numberPromise = new Promise((resolve, reject) => {resolve(10);resolve(20);})numberPromise.then(value => console.log(`Promise ${value}`));const numberObservables = new Observable(observer => {observer.next(10);observer.next(20);});numberObservables.subscribe(value => console.log(`Observables ${value}`));
Example Output

--

--

--

Technical Speaker | Computer Engineer | Full Stack Web Developer | ML Enthusiast | * Knowledge Shared = Knowledge² *

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Building Houses Is Similar To Building Websites

Next.js meets ASP .NET Core — a story of performance and love at long tail

Intro to MongoDB

Hiding tabs dynamically in Ionic 4

Deploying React with NodeJS Backend on GCP Cloud Run from Cloud Source Repositories

What is javascript?

Unit and Integration tests for Angular components. Part 1 out of 3.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vaibhav Bhapkar

Vaibhav Bhapkar

Technical Speaker | Computer Engineer | Full Stack Web Developer | ML Enthusiast | * Knowledge Shared = Knowledge² *

More from Medium

Starting with Reactive forms in Angular

HEIC file in Angular

🔑Auth0 in Angular : [Part1]Authenticate your Angular app

Angular 12 @Input And @Output