Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component, OnInit } from '@angular/core';
- import { BehaviorSubject } from 'rxjs/BehaviorSubject';
- import { HttpErrorResponse } from '@angular/common/http';
- import { filter } from 'rxjs/operators/filter'
- import { map } from 'rxjs/operators/map'
- import { tap } from 'rxjs/operators/tap'
- @Component({
- selector: 'sp-root',
- templateUrl: './app.component.html',
- styleUrls: ['./app.component.scss']
- })
- export class AppComponent implements OnInit {
- error = new BehaviorSubject(new HttpErrorResponse({ status: 401 }))
- constructor() {
- }
- ngOnInit(): void {
- this.error
- .pipe(
- filter(httpResponse => httpResponse instanceof HttpErrorResponse),
- map(x => {
- console.log(x)
- console.log('dispatch')
- return x
- })
- )
- .subscribe(x => {
- console.log(x)
- })
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement