Compare commits

...

5 Commits

8 changed files with 69 additions and 12 deletions

View File

@ -1,10 +1,20 @@
import { Component } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { Router, RouterEvent } from '@angular/router';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
})
export class AppComponent {
export class AppComponent implements OnInit{
constructor(private router: Router){ }
ngOnInit(){
document.addEventListener('GoChangeRoute_Callback', (event:any) => {
this.router.navigate([event.detail])
console.log("here")
})
}
title = 'go-web';
}

View File

@ -14,9 +14,10 @@ import { MainModule } from './components/main/main.module';
import { PlaygroundModule } from './components/playground/playground.module';
import { SandboxModule } from './components/sandbox/sandbox.module';
import { SignInModule } from './components/sign-in/sign-in.module';
import { LoadingScreenComponent } from './components/loading-screen/loading-screen.component';
@NgModule({
declarations: [AppComponent],
declarations: [AppComponent, LoadingScreenComponent],
imports: [
BrowserModule,
AppRoutingModule,

View File

@ -0,0 +1 @@
<p>loading-screen works!</p>

View File

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { LoadingScreenComponent } from './loading-screen.component';
describe('LoadingScreenComponent', () => {
let component: LoadingScreenComponent;
let fixture: ComponentFixture<LoadingScreenComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ LoadingScreenComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(LoadingScreenComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,14 @@
import { Component, OnInit } from '@angular/core';
@Component({
templateUrl: './loading-screen.component.html',
styleUrls: ['./loading-screen.component.scss']
})
export class LoadingScreenComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}

View File

@ -1,5 +1,6 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { LoadingScreenComponent } from '../components/loading-screen/loading-screen.component';
import { MainRoutingModule } from '../components/main/routing.module';
import { PlaygroundComponent } from '../components/playground/playground.component';
import { SandboxComponent } from '../components/sandbox/sandbox.component';
@ -11,7 +12,7 @@ const routes: Routes = [
component: PlaygroundComponent,
},
{
path: '',
path: 'main',
loadChildren: () => MainRoutingModule,
},
{
@ -22,6 +23,10 @@ const routes: Routes = [
path: 'sign-in',
component: SignInComponent,
},
{
path: '',
component: LoadingScreenComponent,
},
];
@NgModule({

View File

@ -9,13 +9,16 @@ export interface Go extends Window {
export interface GoCallback extends Window {
SetVersion: (value: string) => void;
GoChangeRoute: (value: string) => void;
}
let { GoGetGames, GoRunGame, GoGetSessions } = window as unknown as Go;
let { SetVersion } = window as unknown as GoCallback;
let { SetVersion, GoChangeRoute } = window as unknown as GoCallback;
let w = window as unknown as GoCallback;
// var register = function <Type>(name: string): void {
// const event = new CustomEvent<Type>(`${name}_Callback`, {
// detail: value
@ -25,11 +28,11 @@ let w = window as unknown as GoCallback;
// w.SetVersion = register<string>('SetVersion')
// (<GoCallback>(<unknown>window)).SetVersion = function <T>(value: T): void {
// const event = new CustomEvent<T>('GetVersion_Callback', {
// detail: value,
// });
// document.dispatchEvent(event);
// };
(<GoCallback>(<unknown>window)).GoChangeRoute = function <T>(value: T): void {
const event = new CustomEvent<T>('GoChangeRoute_Callback', {
detail: value,
});
document.dispatchEvent(event);
};
export { GoGetGames, GoGetSessions, SetVersion, GoRunGame };
export { GoGetGames, GoGetSessions, SetVersion, GoRunGame, GoChangeRoute };