UNPKG

marko-widgets

Version:

Module to support binding of behavior to rendered UI components rendered on the server or client

40 lines (31 loc) 907 B
module.exports = require('marko-widgets').defineComponent({ template: require.resolve('./template.marko'), getTemplateData: function(state, input) { return { name: input.name, messageCount: input.messageCount }; }, init: function() { this.lifecycleEvents = []; this.recordWidgetLifecycleEvent('init'); }, onRender: function(eventArg) { this.recordWidgetLifecycleEvent(eventArg.firstRender ? 'onRender:firstRender' : 'onRender' ); }, onBeforeDestroy: function() { this.recordWidgetLifecycleEvent('onBeforeDestroy'); }, onDestroy: function() { this.recordWidgetLifecycleEvent('onDestroy'); }, onBeforeUpdate: function() { this.recordWidgetLifecycleEvent('onBeforeUpdate'); }, onUpdate: function() { this.recordWidgetLifecycleEvent('onUpdate'); }, recordWidgetLifecycleEvent: function(name) { this.lifecycleEvents.push(name); } });