# HG changeset patch # User Lucas Thompson # Date 1499366838 -3600 # Node ID 7f9fb84816b9216fe339704549cf4fa9f6694112 # Parent 023fbba200d2bec85c3ef5deb8d6f9cd9813c61e Introduce a singleton / service for communicating errors / or other notifications (there aren't any yet) - using MdSnackBar internally. diff -r 023fbba200d2 -r 7f9fb84816b9 src/app/app.module.ts --- a/src/app/app.module.ts Thu Jul 06 12:52:24 2017 +0100 +++ b/src/app/app.module.ts Thu Jul 06 19:47:18 2017 +0100 @@ -42,6 +42,7 @@ ActionTrayComponent } from './actions/action-tray.component'; import {RecordRtcMediaRecorder} from './services/audio-recorder/RecordRtcMediaRecorder'; +import {NotificationService} from './services/notifications/notifications.service'; export function createAudioContext(): AudioContext { return new ( @@ -163,7 +164,8 @@ {provide: 'UrlResourceLifetimeManager', useFactory: createUrlResourceManager}, {provide: 'ResourceReader', useFactory: createResourceReader}, {provide: 'DimensionObservable', useFactory: createWindowDimensionObservable}, - RenderLoopService + RenderLoopService, + NotificationService ], bootstrap: [AppComponent] }) diff -r 023fbba200d2 -r 7f9fb84816b9 src/app/services/notifications/notifications.service.ts --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/app/services/notifications/notifications.service.ts Thu Jul 06 19:47:18 2017 +0100 @@ -0,0 +1,18 @@ +/** + * Created by lucast on 06/07/2017. + */ +import {Injectable} from '@angular/core'; +import {MdSnackBar} from '@angular/material'; +@Injectable() +export class NotificationService { + constructor(private snackBar: MdSnackBar) {} + + displayError(message: string): void { + // TODO perhaps actual distinguish this as an error? + this.displayMessage(message); + } + + private displayMessage(message: string): void { + this.snackBar.open(message, 'Dismiss', {duration: 5000}); + }; +} diff -r 023fbba200d2 -r 7f9fb84816b9 src/app/ugly-material.module.ts --- a/src/app/ugly-material.module.ts Thu Jul 06 12:52:24 2017 +0100 +++ b/src/app/ugly-material.module.ts Thu Jul 06 19:47:18 2017 +0100 @@ -5,7 +5,7 @@ MdButtonModule, MdCardModule, MdIconModule, MdListModule, MdProgressBarModule, MdProgressSpinnerModule, MdSelectModule, - MdSidenavModule, + MdSidenavModule, MdSnackBarModule, MdToolbarModule } from '@angular/material'; import {NgModule} from '@angular/core'; @@ -21,7 +21,8 @@ MdProgressSpinnerModule, MdProgressBarModule, MdCardModule, - MdListModule + MdListModule, + MdSnackBarModule ]; @NgModule({