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 { MatIconModule } from '@angular/material/icon';
|
||||||
import { MatListModule } from '@angular/material/list';
|
import { MatListModule } from '@angular/material/list';
|
||||||
import { MatRadioModule } from '@angular/material/radio';
|
import { MatRadioModule } from '@angular/material/radio';
|
||||||
|
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
||||||
import { MatToolbarModule } from '@angular/material/toolbar';
|
import { MatToolbarModule } from '@angular/material/toolbar';
|
||||||
|
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
@@ -29,6 +30,7 @@ const materialModules = [
|
|||||||
MatIconModule,
|
MatIconModule,
|
||||||
MatListModule,
|
MatListModule,
|
||||||
MatRadioModule,
|
MatRadioModule,
|
||||||
|
MatSnackBarModule,
|
||||||
MatToolbarModule
|
MatToolbarModule
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||||
import { Actions, createEffect, ofType } from '@ngrx/effects';
|
import { Actions, createEffect, ofType } from '@ngrx/effects';
|
||||||
|
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
@@ -31,12 +32,17 @@ export class GameEffects {
|
|||||||
this.actions$.pipe(
|
this.actions$.pipe(
|
||||||
ofType(GameActions.playMatchFailure),
|
ofType(GameActions.playMatchFailure),
|
||||||
map(action => action.error),
|
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 }
|
), { dispatch: false }
|
||||||
);
|
);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly gameApi: GameService,
|
private readonly gameApi: GameService,
|
||||||
|
private readonly matSackBar: MatSnackBar,
|
||||||
private readonly actions$: Actions
|
private readonly actions$: Actions
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user