mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-22 02:10:12 +01:00
chore(build): dependencies and config updates
This commit is contained in:
parent
1ba236a067
commit
04a57b7b98
11 changed files with 650 additions and 614 deletions
|
|
@ -3,7 +3,7 @@ import { BrowserModule } from '@angular/platform-browser';
|
|||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { HttpModule } from '@angular/http';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { removeNgStyles, createNewHosts } from '@angularclass/hmr';
|
||||
import { removeNgStyles, createNewHosts, createInputTransfer } from '@angularclass/hmr';
|
||||
|
||||
/*
|
||||
* Platform and Environment providers/directives/pipes
|
||||
|
|
@ -13,7 +13,7 @@ import { routing } from './app.routing';
|
|||
|
||||
// App is our top level component
|
||||
import { App } from './app.component';
|
||||
import { AppState } from './app.service';
|
||||
import { AppState, InteralStateType } from './app.service';
|
||||
import { GlobalState } from './global.state';
|
||||
import { NgaModule } from './theme/nga.module';
|
||||
import { PagesModule } from './pages/pages.module';
|
||||
|
|
@ -24,6 +24,12 @@ const APP_PROVIDERS = [
|
|||
GlobalState
|
||||
];
|
||||
|
||||
type StoreType = {
|
||||
state: InteralStateType,
|
||||
restoreInputValues: () => void,
|
||||
disposeOldHosts: () => void
|
||||
};
|
||||
|
||||
/**
|
||||
* `AppModule` is the main entry point into Angular2's bootstraping process
|
||||
*/
|
||||
|
|
@ -51,28 +57,37 @@ const APP_PROVIDERS = [
|
|||
export class AppModule {
|
||||
|
||||
constructor(public appRef: ApplicationRef, public appState: AppState) {
|
||||
|
||||
}
|
||||
|
||||
hmrOnInit(store) {
|
||||
hmrOnInit(store: StoreType) {
|
||||
if (!store || !store.state) return;
|
||||
console.log('HMR store', store);
|
||||
console.log('HMR store', JSON.stringify(store, null, 2));
|
||||
// set state
|
||||
this.appState._state = store.state;
|
||||
// set input values
|
||||
if ('restoreInputValues' in store) {
|
||||
let restoreInputValues = store.restoreInputValues;
|
||||
setTimeout(restoreInputValues);
|
||||
}
|
||||
this.appRef.tick();
|
||||
delete store.state;
|
||||
delete store.restoreInputValues;
|
||||
}
|
||||
|
||||
hmrOnDestroy(store) {
|
||||
hmrOnDestroy(store: StoreType) {
|
||||
const cmpLocation = this.appRef.components.map(cmp => cmp.location.nativeElement);
|
||||
// recreate elements
|
||||
// save state
|
||||
const state = this.appState._state;
|
||||
store.state = state;
|
||||
// recreate root elements
|
||||
store.disposeOldHosts = createNewHosts(cmpLocation);
|
||||
// save input values
|
||||
store.restoreInputValues = createInputTransfer();
|
||||
// remove styles
|
||||
removeNgStyles();
|
||||
}
|
||||
|
||||
hmrAfterDestroy(store) {
|
||||
hmrAfterDestroy(store: StoreType) {
|
||||
// display new elements
|
||||
store.disposeOldHosts();
|
||||
delete store.disposeOldHosts;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue