class View extends Listenable { /** * The constructor accepts a DOM element as a parameter. If it is omitted, a new element is created using the constructor name in kebab case. */ constructor(element = null) { super(); this.element = element; if (!this.element) { this.element = document.createElement(this.constructor.name.toKebabCase()); this.build(this.element); } } /** * The build function is called in the constructor when no element was passed as the base. * Override it to create custom subviews or manipulate the root element. * Don't forget to return the element in the end! */ build(element) { return element; } /** * Called once the view has been processed by UIKit during the view controller initialization. */ viewDidLoad() { } /** * Called everytime before the view is shown. * The layout is already done at this step, so it's safe to use scrollWidth and scrollHeight and what not. */ viewWillAppear() { } /** * Called everytime after the view is shown. */ viewDidAppear() { } /** * Called everytime before the view is hidden. */ viewWillDisappear() { } /** * Called everytime after the view is hidden. */ viewDidDisappear() { } } UIKit.registerViewType(View);