Advertisement
xapu

Untitled

Oct 16th, 2018
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. import { Component, OnInit } from '@angular/core';
  2. import { BehaviorSubject } from 'rxjs/BehaviorSubject';
  3. import { HttpErrorResponse } from '@angular/common/http';
  4. import { filter } from 'rxjs/operators/filter'
  5. import { map } from 'rxjs/operators/map'
  6. import { tap } from 'rxjs/operators/tap'
  7. @Component({
  8. selector: 'sp-root',
  9. templateUrl: './app.component.html',
  10. styleUrls: ['./app.component.scss']
  11. })
  12. export class AppComponent implements OnInit {
  13.  
  14.  
  15. error = new BehaviorSubject(new HttpErrorResponse({ status: 401 }))
  16.  
  17. constructor() {
  18.  
  19. }
  20. ngOnInit(): void {
  21.  
  22. this.error
  23. .pipe(
  24. filter(httpResponse => httpResponse instanceof HttpErrorResponse),
  25. map(x => {
  26. console.log(x)
  27. console.log('dispatch')
  28. return x
  29. })
  30. )
  31. .subscribe(x => {
  32. console.log(x)
  33. })
  34.  
  35. }
  36.  
  37.  
  38.  
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement