diff options
Diffstat (limited to 'client/src/main.browser.ts')
-rw-r--r-- | client/src/main.browser.ts | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/client/src/main.browser.ts b/client/src/main.browser.ts index 70bf48537..f627ba7df 100644 --- a/client/src/main.browser.ts +++ b/client/src/main.browser.ts | |||
@@ -1,20 +1,37 @@ | |||
1 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | 1 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; |
2 | import { decorateModuleRef } from './app/environment'; | 2 | import { decorateModuleRef } from './app/environment'; |
3 | import { bootloader } from '@angularclass/hmr'; | 3 | |
4 | /* | 4 | /** |
5 | * App Module | 5 | * App Module |
6 | * our top level module that holds all of our components | 6 | * our top level module that holds all of our components |
7 | */ | 7 | */ |
8 | import { AppModule } from './app'; | 8 | import { AppModule } from './app'; |
9 | 9 | ||
10 | /* | 10 | /** |
11 | * Bootstrap our Angular app with a top level NgModule | 11 | * Bootstrap our Angular app with a top level NgModule |
12 | */ | 12 | */ |
13 | export function main(): Promise<any> { | 13 | export function main(): Promise<any> { |
14 | return platformBrowserDynamic() | 14 | return platformBrowserDynamic() |
15 | .bootstrapModule(AppModule) | 15 | .bootstrapModule(AppModule) |
16 | .then(decorateModuleRef) | 16 | .then(decorateModuleRef) |
17 | .catch(err => console.error(err)); | 17 | .catch((err) => console.error(err)); |
18 | } | 18 | } |
19 | 19 | ||
20 | bootloader(main); | 20 | /** |
21 | * Needed for hmr | ||
22 | * in prod this is replace for document ready | ||
23 | */ | ||
24 | switch (document.readyState) { | ||
25 | case 'loading': | ||
26 | document.addEventListener('DOMContentLoaded', _domReadyHandler, false); | ||
27 | break; | ||
28 | case 'interactive': | ||
29 | case 'complete': | ||
30 | default: | ||
31 | main(); | ||
32 | } | ||
33 | |||
34 | function _domReadyHandler() { | ||
35 | document.removeEventListener('DOMContentLoaded', _domReadyHandler, false); | ||
36 | main(); | ||
37 | } | ||