The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Using the Async Pipe in Angular 2

Using the Async Pipe in Angular 2

5:27
The Async Pipe in Angular 2 can reduce boilerplate and mental overhead when dealing with observables and promises. This lesson explores how the Async Pipe works, the code it eliminates, and demonstrates common use-cases within your applications!
Watch this lesson now
Avatar
egghead.io

The Async Pipe in Angular 2 can reduce boilerplate and mental overhead when dealing with observables and promises. This lesson explores how the Async Pipe works, the code it eliminates, and demonstrates common use-cases within your applications!

Avatar
Brutalis

Thanks for this video, is it possible to use the async pipe in typescript code?
If so, how can we use it (with observables)?

In reply to egghead.io
Avatar
Brian

Hello, thanks for watching. In TypeScript you will just call .subscribe on the observable. Behind the scenes the AsynPipe is just subscribing to the observable, keeping track of the last emitted value, and triggering change detection when this value changes. It also makes sure to clean up the subscription when the component is destroyed, this is equivalent to calling unsubscribe in ngOnDestroy. Hope this helps, let me know if you have any other questions! :)

In reply to Brutalis
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?