2020-01-27 18:40:18 +00:00
|
|
|
import { Component, OnInit, OnDestroy, Input } from '@angular/core';
|
|
|
|
|
import { MessageBus, Events } from 'protocol';
|
|
|
|
|
import { interval } from 'rxjs';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'ng-devtools',
|
|
|
|
|
templateUrl: './devtools.component.html',
|
|
|
|
|
styleUrls: ['./devtools.component.css'],
|
|
|
|
|
})
|
|
|
|
|
export class DevToolsComponent implements OnInit, OnDestroy {
|
|
|
|
|
angularExists: boolean | null = null;
|
2020-01-29 17:10:57 +00:00
|
|
|
angularVersion: string | undefined = undefined;
|
2020-01-27 18:40:18 +00:00
|
|
|
@Input() messageBus: MessageBus<Events>;
|
|
|
|
|
|
|
|
|
|
private _interval$ = interval(500).subscribe(() => this.messageBus.emit('queryNgAvailability'));
|
|
|
|
|
|
2020-01-29 00:29:23 +00:00
|
|
|
ngOnInit(): void {
|
2020-01-27 18:40:18 +00:00
|
|
|
console.log('Initialized the devtools UI');
|
|
|
|
|
|
|
|
|
|
this.messageBus.once('ngAvailability', ({ version }) => {
|
2020-01-29 00:29:23 +00:00
|
|
|
this.angularExists = !!version;
|
2020-01-29 17:10:57 +00:00
|
|
|
this.angularVersion = version;
|
2020-01-27 18:40:18 +00:00
|
|
|
this._interval$.unsubscribe();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-29 00:29:23 +00:00
|
|
|
ngOnDestroy(): void {
|
2020-01-27 18:40:18 +00:00
|
|
|
this._interval$.unsubscribe();
|
|
|
|
|
}
|
|
|
|
|
}
|