mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-16 18:17:31 +08:00
perf(angular): bundle size improvements for angular (#16966)
This commit is contained in:
26
angular/src/directives/proxies-utils.ts
Normal file
26
angular/src/directives/proxies-utils.ts
Normal file
@ -0,0 +1,26 @@
|
||||
/* tslint:disable */
|
||||
import { fromEvent } from 'rxjs';
|
||||
|
||||
export function proxyInputs(Cmp: any, inputs: string[]) {
|
||||
const Prototype = Cmp.prototype;
|
||||
inputs.forEach(item => {
|
||||
Object.defineProperty(Prototype, item, {
|
||||
get() { return this.el[item]; },
|
||||
set(val: any) { this.el[item] = val; },
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function proxyMethods(Cmp: any, methods: string[]) {
|
||||
const Prototype = Cmp.prototype;
|
||||
methods.forEach(methodName => {
|
||||
Prototype[methodName] = function() {
|
||||
const args = arguments;
|
||||
return this.el.componentOnReady().then((el: any) => el[methodName].apply(el, args));
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function proxyOutputs(instance: any, el: any, events: string[]) {
|
||||
events.forEach(eventName => instance[eventName] = fromEvent(el, eventName));
|
||||
}
|
Reference in New Issue
Block a user