import { Injectable } from '@angular/core'; import { Observable, Subject } from 'rxjs'; /** * The state of the subscriptions' socket that the app cares about: when it * comes back after a cut. Whatever happened meanwhile was not received, so * views reload when it does. */ @Injectable({ providedIn: 'root' }) export class RealtimeConnection { private readonly back = new Subject(); /** Each time the socket reconnects (not the first time it connects). */ readonly reconnected$: Observable = this.back.asObservable(); /** Called by the GraphQL client. */ reconnected(): void { this.back.next(); } }