-
Notifications
You must be signed in to change notification settings - Fork 171
/
app.component.ts
40 lines (36 loc) · 1.12 KB
/
app.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { Component, ViewEncapsulation, OnInit } from '@angular/core';
import {
addInitListener,
addContextUpdateListener,
sendCustomMessage,
addInactiveListener
} from '@kyma-project/luigi-client';
import {
LuigiContextService,
ILuigiContextTypes
} from './services/luigi-context.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class AppComponent implements OnInit {
public title = 'app';
constructor(private luigiService: LuigiContextService) {}
ngOnInit() {
addInitListener(context => this.onLuigiContext('init', context));
addContextUpdateListener(context => this.onLuigiContext('update', context));
addInactiveListener(() => {
console.debug(
'inactiveListener: micro frontend is now in the background'
);
});
}
private onLuigiContext(contextType: ILuigiContextTypes, context: any): void {
this.luigiService.setContext({ contextType, context });
if (contextType === 'init') {
sendCustomMessage({ id: 'my-micro-frontend-is-ready' });
}
}
}