Angular Interview Questions - Promise Vs Observable - With Practical Demo
ฝัง
- เผยแพร่เมื่อ 28 พ.ค. 2023
- In the series of Angular Interview question , In this video we will cover , what is the differences we have between Promise and Observable.
Promise is part of JavaScript and Observable is part of Rxjs Library.
Promise and Observable , both are used to achieve asynchronous functionality in Angular.
Differences:
-----------------------------------------------------------------------------------------------------------------------
****************
Promise -
****************
1. Part of JavaScript
2. Callback (resolve , reject)
3. Eager Loading
4. Return single value using then()
5. Non cancelable
6. Always async
7. Do not provide operators
****************
Observable -
****************
1. Part of Rxjs (Reactive extension of JavaScript)
2. Callback (success , error , complete)
3. Lazy Loading
4. Return multiple value using subscribe()
5. Cancelable/unsubscribe
6. Behave async and sync both
7. Offer operations like map, filter, reduce, retry replay, forEach, and many more
Used Command:
------------------------------------------------------------------------------------------------------------------
Used Command:
-----------------------------------------------------------------------------------------------------------------------
ng serve -o
Follow Me:
-----------------------------------------------------------------------------------------------------------------------
FACEBOOK - / kyprogramming
TWITTER - / kyprogramming
TH-cam Channel -
-----------------------------------------------------------------------------------------------------------------------
/ @kyprogramming
If you have not subscribed yet then please SUBSCRIBE and do not forgot to press the bell icon in order to get notification for all my upcoming videos as well as please like and share to the others as well.
Interview Questions -
-----------------------------------------------------------------------------------------------------------------------
1. What is the difference between Promise and Observable?
2. What are the callback functions we have in Promise and Observable?
3. Is Promise eager loading and how?
4. Is Observable lazy loading how?
5. How to create and execute Promise and Observable?
6. How to unsubscribe Observable?
7. Is Promise asynchronous or synchronous?
8. How Observable perform synchronous and asynchronous both?
9. How to use the operators in Observable? - วิทยาศาสตร์และเทคโนโลยี
good and simple explanation. Appreciations!!
Glad you liked it
crystal clear explanation bro. Amazing
Thank you!
very informative video, i have a question, what if i use toPromise() with observables instead of promise?
You can make a separate video on it. also explain await, async in the same video so that we'll get clear idea.
Thank you Aparna!
.toPromise is utility method from Observable and that is used to convert an Observable into a Promise which resolve promise with the last emited value.
Hope I have answered for your query.
Certainly I will make an video on async and await soon. Thank you for your suggestion.
Thanks
thank u@@kyprogramming
❤
Promises return single value using .then() method, but you have written .next() method.
Thanks you.
Promise use then() and Observable use subscribe() with callback next() function to fetch data.
There was a typing error, I will try to update that.
However I have explained promise in the code by using then() method.
nice but thoda zoom karo
Thank you!!
The bell ring is so annoying
Thank you for letting me know..
I will take care of bell ring from all my upcoming video.