perf(events): bypass ngzone

This commit is contained in:
Adam Bradley
2018-03-02 22:56:39 -06:00
parent b3ff101fa8
commit 7366c38abc
2 changed files with 41 additions and 5 deletions

View File

@ -29,3 +29,40 @@ export { PopoverController, PopoverProxy } from './providers/popover-controller'
export { ToastController, ToastProxy } from './providers/toast-controller';
export * from './types/interfaces';
import { IonicWindow } from './types/interfaces';
const win = (window as IonicWindow);
const Ionic = win.Ionic;
if (!Ionic) {
throw new Error(`ionic.js script missing from index.html`);
} else {
Ionic.ael = function ngAddEventListener(elm, eventName, cb, opts) {
if (elm.__zone_symbol__addEventListener) {
elm.__zone_symbol__addEventListener(eventName, cb, opts);
} else {
elm.addEventListener(eventName, cb, opts);
}
};
Ionic.rel = function ngRemoveEventListener(elm, eventName, cb, opts) {
if (elm.__zone_symbol__removeEventListener) {
elm.__zone_symbol__removeEventListener(eventName, cb, opts);
} else {
elm.removeEventListener(eventName, cb, opts);
}
};
Ionic.raf = function ngRequestAnimationFrame(cb: any) {
if (win.__zone_symbol__requestAnimationFrame) {
win.__zone_symbol__requestAnimationFrame(cb);
} else {
win.requestAnimationFrame(cb);
}
};
}

View File

@ -24,13 +24,12 @@ export interface AngularEscapeHatch extends EscapeHatch {
export interface IonicGlobal {
config: any;
Events: {
subscribe: (topic: string, ...handlers: Function[]) => void;
unsubscribe: (topic: string, handler: Function) => void;
publish: (topic: string, ...args: any[]) => any[];
};
ael: (elm: any, eventName: string, cb: Function, opts: any) => void;
raf: Function;
rel: (elm: any, eventName: string, cb: Function, opts: any) => void;
}
export interface IonicWindow extends Window {
Ionic: IonicGlobal;
__zone_symbol__requestAnimationFrame: Function;
}