Files
ionic-framework/angular/src/directives/proxies-utils.ts

27 lines
784 B
TypeScript

/* 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));
}