Friday, 15 January 2021

Observarble subscription and pipe

import { Subscription } from 'rxjs';

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


 Observable

// Do something with return data

.pipe(

// Always execute no matter wut

finalize( ()=> {

  this.loader = false;

})

// Do something with return data but do not mutate it. Can do console.log

pipe( (returnData) = > {


})

// MergeMap mutate the data, for example change it to an observable

mergeMap( (returnData) => {


})

)

// Handle data by next(data)

. subscribe ( (returnData) => {


})

.catch ( (error) => {


})

No comments:

Post a Comment