abstract class View {
/**
* Data inserted into the view via constructor.
*/
public data: any;
/**
* Yields all methods (i.e., content type handlers) of the view instance.
*/
public *methods() {
const obj = this;
const getProps = function* (object) {
if (object !== Object.prototype) {
for (let name of Object.getOwnPropertyNames(object)) {
const fn = object[name];
if (fn instanceof Function && name !== 'constructor' && name !== 'methods') {
yield name;
}
}
yield* getProps(Object.getPrototypeOf(object));
}
};
yield* getProps(obj);
}
constructor(data?: any) {
this.data = data;
}
}
export { View as default };
|