-
-
Notifications
You must be signed in to change notification settings - Fork 310
/
main.ts
55 lines (47 loc) · 1.65 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { enableProdMode, ApplicationRef } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
import { handleExternalLinks } from 'app/utils/events';
import { debug } from 'app/utils/logger';
import { enableDebugTools } from '@angular/platform-browser';
import { AltairConfig, AltairConfigOptions, setAltairConfig } from 'app/config';
import { reducerToken, getReducer } from 'app/reducers';
import { handleDeprecations } from 'app/utils/deprecated';
let initialized = false;
(window as any).AltairGraphQL = {
init(config: AltairConfigOptions = {}) {
if (initialized) {
return;
}
const altairConfig = new AltairConfig(config);
setAltairConfig(altairConfig);
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic(
[
// Setting reducer provider here (after setting altair config),
// so the reducers are initialized with the right config
{
provide: reducerToken,
useValue: getReducer(),
},
{
provide: AltairConfig,
useValue: altairConfig,
},
]
).bootstrapModule(AppModule, {
preserveWhitespaces: true
}).then(moduleRef => {
const applicationRef = moduleRef.injector.get(ApplicationRef);
const componentRef = applicationRef.components[0];
enableDebugTools(componentRef);
}).catch(err => debug.log('Error bootstrapping application:', err));
handleExternalLinks();
handleDeprecations();
initialized = true;
},
plugins: {},
};