var Widget = require('web.Widget'); var Counter = require('myModule.Counter');
var MyWidget = Widget.extend({ start: function () { this.counter = new Counter(this); this.counter.on('valuechange', this, this._onValueChange); var def = this.counter.appendTo(this.$el); return $.when(def, this._super.apply(this, arguments); }, _onValueChange: function (val) { // do something with val }, });
// in Counter widget, we need to call the trigger method: