Skip to content

Instantly share code, notes, and snippets.

@GrillPhil
Created May 23, 2018 08:35
Show Gist options
  • Save GrillPhil/45e7a481094640e74f5e8eb009cb12cb to your computer and use it in GitHub Desktop.
Save GrillPhil/45e7a481094640e74f5e8eb009cb12cb to your computer and use it in GitHub Desktop.
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