1
0

Add host-window.service

This commit is contained in:
Giuseppe Digilio
2017-05-25 17:27:31 +02:00
parent 857fd448d4
commit c5c0bb776b
13 changed files with 1080 additions and 527 deletions

View File

@@ -8,9 +8,10 @@ import {
import { TranslateService } from "@ngx-translate/core";
import { HostWindowState } from "./shared/host-window.reducer";
import { Store } from "@ngrx/store";
import { HostWindowResizeAction } from "./shared/host-window.actions";
import { HostWindowResizeAction } from "./shared/host-window.actions";
import { EnvConfig, GLOBAL_CONFIG, GlobalConfig } from '../config';
import { NativeWindowRef, NativeWindowService } from "./shared/window.service";
@Component({
changeDetection: ChangeDetectionStrategy.Default,
@@ -23,6 +24,7 @@ export class AppComponent implements OnInit {
constructor(
@Inject(GLOBAL_CONFIG) public EnvConfig: GlobalConfig,
@Inject(NativeWindowService) private _window: NativeWindowRef,
private translate: TranslateService,
private store: Store<HostWindowState>
) {
@@ -33,6 +35,7 @@ export class AppComponent implements OnInit {
}
ngOnInit() {
this.onInit();
const env: string = EnvConfig.production ? "Production" : "Development";
const color: string = EnvConfig.production ? "red" : "green";
console.info(`Environment: %c${env}`, `color: ${color}; font-weight: bold;`);
@@ -45,4 +48,12 @@ export class AppComponent implements OnInit {
);
}
private onInit(): void {
if (typeof this._window !== 'undefined') {
this.store.dispatch(
new HostWindowResizeAction(this._window.nativeWindow.innerWidth, this._window.nativeWindow.innerHeight)
);
}
}
}