mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
27 lines
784 B
TypeScript
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));
|
|
}
|