Created
May 23, 2018 08:35
-
-
Save GrillPhil/45e7a481094640e74f5e8eb009cb12cb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import { Component, OnInit } from '@angular/core'; | |
import { SignalRService } from './signalr.service'; | |
import { MatSnackBar } from '@angular/material'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styles: [] | |
}) | |
export class AppComponent implements OnInit { | |
private readonly _signalRService: SignalRService; | |
private readonly _snackBar: MatSnackBar; | |
message: string; | |
constructor(signalRService: SignalRService, snackBar: MatSnackBar) { | |
this._signalRService = signalRService; | |
this._snackBar = snackBar; | |
} | |
ngOnInit() { | |
this._signalRService.init(); | |
this._signalRService.messages.subscribe(message => { | |
this._snackBar.open(message); | |
}); | |
} | |
send() { | |
this._signalRService.send(this.message).subscribe(() => {}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment