Angular promises vs observables

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 ก.ย. 2024
  • Text version of the video
    csharp-video-tu...
    Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our TH-cam channel. Hope you can help.
    / @aarvikitchen5572
    Slides
    csharp-video-tu...
    Angular 2 Tutorial playlist
    • Angular 2 tutorial for...
    Angular 2 Text articles and slides
    csharp-video-tu...
    All Dot Net and SQL Server Tutorials in English
    www.youtube.co...
    All Dot Net and SQL Server Tutorials in Arabic
    / kudvenkatarabic
    In this video we will discuss the differences between promises and observables. In Angular 2, to work with asynchronous data we can use either Promises or Observables. In our previous videos in this series, we discussed using both Observables and Promises. There are several differences between Promises and Observables. In this video let's discuss these differences.
    A Promise emits a single value where as an Observable emits multiple values over a period of time. You can think of an Observable like a stream which emits multiple items over a period of time and the same callback function is called for each item emitted. So with an Observable we can use the same API to handle asynchronous data whether that data is emitted as a single value or multiple values over a period of time.
    A Promise is not lazy where as an Observable is Lazy.
    A Promise cannot be cancelled where as an Observable can be cancelled using the unsubscribe() method
    Observable provides operators like map, forEach, filter, reduce, retry, retryWhen etc

ความคิดเห็น • 54