-
Notifications
You must be signed in to change notification settings - Fork 240
@fires
Rene Saarsoo edited this page May 28, 2013
·
1 revision
Synopsis:
@fires eventName
Documents events fired by a @method. For example:
/**
* Shows the component
* @fires show
*/
show: function() {
this.setVisible(true);
this.fireEvent("show", this);
},
When the code of the method contains a calls to this.fireEvent
, JSDuck will
automatically detect the events fired. It even works when this
is aliased:
/**
* Shows the component
*/
show: function() {
var me = this;
if (me.setVisible(true)) {
me.fireEvent("show", this);
}
},
Additionally this.fireEvent
calls are picked up from methods called by this method:
/**
* Shows the component.
*/
show: function() {
this.setVisible(true);
},
/**
* Shows or hides the component.
*/
setVisible: function(visible) {
if (visible) {
this.fireEvent("show", this);
} else {
this.fireEvent("hide", this);
}
}
In the above case setVisible()
is detected to fire show
and hide
events,
and because the show()
method calls setVisible()
it too will automatically
list show
and hide
as the events it fires.
Of course show()
never actually fires hide
, so the auto-detection has gone
a bit overboard, but we can easily correct this by adding an explicit @fires show
to show()
method, overriding the auto-detected values.