Created
March 29, 2019 15:20
-
-
Save VicAv99/7e45efee0abec94dbc40cb7ffbb7ba40 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/core/interceptors/blocker.interceptor.ts | |
import { Injectable } from ‘@angular/core’; | |
import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent } from ‘@angular/common/http’; | |
import { MatSnackBar } from ‘@angular/material’; | |
import { Observable } from ‘rxjs’; | |
@Injectable({ | |
providedIn: ‘root’ | |
}) | |
export class BlockerInterceptor implements HttpInterceptor { | |
constructor(private snackbar: MatSnackBar) { } | |
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { | |
if (req.body && req.body.blocker) { | |
const message = ‘Reminder: Your teammates are available for help’; | |
this.notify(message); | |
} | |
return next.handle(req); | |
} | |
private notify(message: string) { | |
this.snackbar.open(message, ‘Ok’, { duration: 3000 }); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment