import { Observable, Subject } from 'rxjs' import { ViewRef } from '@angular/core' export abstract class BaseTabComponent { private static lastTabID = 0 id: number title: string customTitle: string hasActivity = false hasFocus = false hostView: ViewRef protected titleChange = new Subject() protected focused = new Subject() protected blurred = new Subject() get focused$ (): Observable { return this.focused } get blurred$ (): Observable { return this.blurred } get titleChange$ (): Observable { return this.titleChange } constructor () { this.id = BaseTabComponent.lastTabID++ this.focused$.subscribe(() => { this.hasFocus = true }) this.blurred$.subscribe(() => { this.hasFocus = false }) } setTitle (title: string) { this.title = title if (!this.customTitle) { this.titleChange.next(title) } } displayActivity (): void { this.hasActivity = true } getRecoveryToken (): any { return null } async canClose (): Promise { return true } emitFocused () { this.focused.next() } emitBlurred () { this.blurred.next() } destroy (): void { this.focused.complete() this.blurred.complete() this.titleChange.complete() } }