Add status callback

This commit is contained in:
Gregory Brzezinski 2022-11-11 16:44:08 +03:00
parent 5d15b7648d
commit 077fe04688
3 changed files with 16 additions and 4 deletions

View File

@ -4,7 +4,7 @@
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
"start": "ng serve", "start": "ng serve",
"build": "ng build", "build": "ng build --output-hashing none",
"watch": "ng build --watch --configuration development", "watch": "ng build --watch --configuration development",
"test": "ng test" "test": "ng test"
}, },

View File

@ -1,5 +1,5 @@
import { Component, OnInit, Input } from '@angular/core'; import { Component, OnInit, Input } from '@angular/core';
import { GoSetStatus } from 'src/app/services/go';
@Component({ @Component({
templateUrl: './loading-screen.component.html', templateUrl: './loading-screen.component.html',
styleUrls: ['./loading-screen.component.scss'] styleUrls: ['./loading-screen.component.scss']
@ -14,6 +14,10 @@ export class LoadingScreenComponent implements OnInit {
} }
ngOnInit(): void { ngOnInit(): void {
document.addEventListener('GoSetStatus_Callback', (event:any) => {
this.SetStatus(event.detail)
console.log("Set loading screen status: " + event.detail)
})
} }
} }

View File

@ -12,10 +12,11 @@ export interface Go extends Window {
export interface GoCallback extends Window { export interface GoCallback extends Window {
SetVersion: (value: string) => void; SetVersion: (value: string) => void;
GoChangeRoute: (value: string) => void; GoChangeRoute: (value: string) => void;
GoSetStatus: (value: string) => void;
} }
let { GoGetGames, GoRunGame, GoGetSessions, GoRunSession, GoWebViewInit } = window as unknown as Go; let { GoGetGames, GoRunGame, GoGetSessions, GoRunSession, GoWebViewInit } = window as unknown as Go;
let { SetVersion, GoChangeRoute } = window as unknown as GoCallback; let { SetVersion, GoChangeRoute, GoSetStatus } = window as unknown as GoCallback;
let w = window as unknown as GoCallback; let w = window as unknown as GoCallback;
@ -37,4 +38,11 @@ let w = window as unknown as GoCallback;
document.dispatchEvent(event); document.dispatchEvent(event);
}; };
export { GoGetGames, GoGetSessions, SetVersion, GoRunGame, GoChangeRoute, GoWebViewInit, GoRunSession }; (<GoCallback>(<unknown>window)).GoSetStatus = function <T>(value: T): void {
const event = new CustomEvent<T>('GoSetStatus_Callback', {
detail: value,
});
document.dispatchEvent(event);
};
export { GoGetGames, GoGetSessions, SetVersion, GoRunGame, GoChangeRoute, GoSetStatus, GoWebViewInit, GoRunSession };