Tuesday, November 26, 2019

finalize in a pipe off of an Observable

The finalize will run whenever data is done loading.

this.mySubscription = foo.pipe(finalize(() => {
      console.log('done loading');
   })).subscribe(data => {
      this.data = data;
   });

 
 

In Angular 5 you import this stuff the same way you would tap and catchError like so:

import { catchError, finalize, tap } from "rxjs/operators";

No comments:

Post a Comment