An event emitter designed for communication between react components.
Trivial example showing the special events (_drop and _all) and the
partial application emitter ReactBus.handle
(good for event handlers).
var AppBus = new ReactBus();
AppBus.on("_drop", function (e, args) {
console.log("events of type", e, "arent being handled");
});
AppBus.on("_all", function (e, args) {
console.log(e, "with arguments", args.join(","))
});
var Button = React.createClass({
render: function () {
return React.DOM.button({ onClick: AppBus.handle("click") }, "Button");
};
});
Call fn
every time event e
triggers.
Call fn
once when event e
triggers.
Stop fn
from being called when event e
triggers.
Remove all listeners from event e
.
Trigger an event e
passing arguments args...
to listeners.
Return a function fn
when called triggers event e
with arguments
args..., event
. Useful for DOM event handlers like onClick
.
All events except _all
and _drop
trigger this event with e
as the
event and [args]
as the arguments passed to the event e
. Useful for
tracking events for analytics.
Events that do not have any listeners trigger this event with e
as the
event and [args]
as the arguments passed to the event e
. Useful for
debugging any missed events in the system.
MIT