import { NgModule, APP_BOOTSTRAP_LISTENER, ApplicationRef } from '@angular/core'
import { ServerModule, ServerTransferStateModule }    		from '@angular/platform-server'
import { BrowserModule } 				from '@angular/platform-browser'

import { AppModule } 					from './modules/app-base/mod.app'
import { AppDebelComponent } 			from './modules/app-base/components/app/cmp.app'

export function onBootstrap(appRef: ApplicationRef) {
	return () => {
		appRef.isStable
			.filter(stable => stable)
			.first()
	};
}

@NgModule({
	bootstrap: [AppDebelComponent],
	imports: [
		BrowserModule.withServerTransition({
			appId: 'kake'
		}),
		ServerModule,
		ServerTransferStateModule,
		AppModule
	],
	providers: [
		{
			provide: APP_BOOTSTRAP_LISTENER,
			useFactory: onBootstrap,
			multi: true,
			deps: [
				ApplicationRef
			]
		},
	]
})
export class ServerAppModule {

}
