perf(angular): bundle size improvements for angular (#16966)

This commit is contained in:
Manu MA
2019-01-07 22:05:36 +01:00
committed by GitHub
parent 45db44abe7
commit 44fb45e2bc
30 changed files with 322 additions and 328 deletions

View 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));
}