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

Why Backend Isn’t Superior To Frontend

Backend developer looking at frontend developers.

React- Your First Custom Hook

Why GitHub Copilot Won’t Render Software Engineers Obsolete

How I created the 1st Full Stack playground

Arrow Functions, the this keyword and Classes in Javascript

How to handle HTTP reponse using axios

Use Memoization in React with React Memo

Building a Controlled Form using React hooks.

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

Reusable Presentational Components in Angular 6+

Disabling Form Controls When Working With Reactive Forms in Angular

RxJS to catch or not to catch

Use of @HostBinding and @HostListener in Angular

finally look when host listener and host binding added