Added snackbar error handling
This commit is contained in:
@@ -11,6 +11,7 @@ import { MatCardModule } from '@angular/material/card';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatListModule } from '@angular/material/list';
|
||||
import { MatRadioModule } from '@angular/material/radio';
|
||||
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { MatToolbarModule } from '@angular/material/toolbar';
|
||||
|
||||
import { AppComponent } from './app.component';
|
||||
@@ -29,6 +30,7 @@ const materialModules = [
|
||||
MatIconModule,
|
||||
MatListModule,
|
||||
MatRadioModule,
|
||||
MatSnackBarModule,
|
||||
MatToolbarModule
|
||||
];
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { Actions, createEffect, ofType } from '@ngrx/effects';
|
||||
|
||||
import { of } from 'rxjs';
|
||||
@@ -31,12 +32,17 @@ export class GameEffects {
|
||||
this.actions$.pipe(
|
||||
ofType(GameActions.playMatchFailure),
|
||||
map(action => action.error),
|
||||
tap(e => console.error(e)) // TODO: replace with material toast service
|
||||
tap(error => {
|
||||
this.matSackBar.open(error.statusText, '', {
|
||||
duration: 1500
|
||||
});
|
||||
})
|
||||
), { dispatch: false }
|
||||
);
|
||||
|
||||
constructor(
|
||||
private readonly gameApi: GameService,
|
||||
private readonly matSackBar: MatSnackBar,
|
||||
private readonly actions$: Actions
|
||||
) { }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user