Files
ionic-framework/angular/src/app-initialize.ts
Mike Hartington 2344d0b272 feat(angular): angular 9 support (#19515)
* init ivy support

* chore(): angular prerelease

* chore: update

* updates

* angular 8 deps

* chore(angular): update sync script

* updates

* chore(): remove console log

* chore(): updates

* chore(): update release script

* fix(): remove comments

* fix(): remove test version

* fix(): failing angular test

* fix(): failing angular tests

* fix(): update ci steps

* fix(): fix sync script

* chore(): refactor angular proxies

* chore(): updates

* chore(): updates

* chore(): lint

* chore(): updates

* chore(ssr): check for window

* chore(): fix virtual scroll angular tests

* chore(): lint

* chore(): add server to link

* chore(scripts): update release script

* chore(): bump version check

* style(scripts): spacing
2019-12-18 18:43:59 -05:00

46 lines
1.4 KiB
TypeScript

import { NgZone } from '@angular/core';
import { applyPolyfills, defineCustomElements } from '@ionic/core/loader';
import { Config } from './providers/config';
import { IonicWindow } from './types/interfaces';
import { raf } from './util/util';
let didInitialize = false;
export const appInitialize = (config: Config, doc: Document, zone: NgZone) => {
return (): any => {
const win: IonicWindow | undefined = doc.defaultView as any;
if (win && typeof (window as any) !== 'undefined') {
if (didInitialize) {
console.warn('Ionic Angular was already initialized. Make sure IonicModule.forRoot() is just called once.');
}
didInitialize = true;
const Ionic = win.Ionic = win.Ionic || {};
Ionic.config = {
...config,
_zoneGate: (h: any) => zone.run(h)
};
const aelFn = '__zone_symbol__addEventListener' in (doc.body as any)
? '__zone_symbol__addEventListener'
: 'addEventListener';
return applyPolyfills().then(() => {
return defineCustomElements(win, {
exclude: ['ion-tabs', 'ion-tab'],
syncQueue: true,
raf,
jmp: (h: any) => zone.runOutsideAngular(h),
ael(elm, eventName, cb, opts) {
(elm as any)[aelFn](eventName, cb, opts);
},
rel(elm, eventName, cb, opts) {
elm.removeEventListener(eventName, cb, opts);
}
});
});
}
};
};