If we don't want to install the ng-connection-service manually, we can still use the 1.0.4 version by adding the following highlighted line to the /ClientApp/package.json file for both of the preceding projects, at the end of the "dependencies" section:
// ...
"zone.js": "0.10.2",
"ng-connection-service": "1.0.4"
// ...
And implement it in our AppComponent's file in the following way:
import { Component } from '@angular/core';
import { ConnectionService } from 'connection-service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
status = 'ONLINE';
isConnected = true;
constructor(private connectionService: ConnectionService) {
this.connectionService.monitor().subscribe(isConnected => {
this.isConnected = isConnected;
if (this.isConnected) {
...