Files
aspnet-core-signalr-angular/app/home/home.component.ts
2016-09-28 13:21:28 +03:00

38 lines
1.0 KiB
TypeScript

import { Component, OnInit } from '@angular/core';
import { FeedService } from '../shared/feed.service';
import { ConnectionState } from '../shared/interfaces';
@Component({
selector: 'home',
templateUrl: 'app/home/home.component.html'
})
export class HomeComponent implements OnInit {
error: any;
constructor(private service: FeedService) { }
ngOnInit() {
this.service.connectionState
.subscribe(
connectionState => {
if (connectionState == ConnectionState.Connected) {
console.log('Connected!');
} else {
console.log(connectionState.toString());
}
},
error => {
this.error = error;
console.log(error);
});
if (this.service.currentState === ConnectionState.Connected) {
console.log(' connected....');
}
else {
console.log('not connected');
}
}
}