Skip to content

Instantly share code, notes, and snippets.

@kara-ryli
Created July 19, 2012 00:00
Show Gist options
  • Save kara-ryli/3139817 to your computer and use it in GitHub Desktop.
Save kara-ryli/3139817 to your computer and use it in GitHub Desktop.
Notify event new subscribers between events that happened on an interval in YUI
/*global YUI*/
YUI().use("event-custom", function (Y) {
var et = new Y.EventTarget(),
ce = et.publish("frob", {
defaultFn: function (event) {
et.frobs += 1;
},
emitFacade: true
});
et.frobs = 0;
ce.monitor("attach", function (handler) {
handler.args[1]({
type: ce.type,
target: ce.currentTarget,
currentTarget: ce.currentTarget,
details: ce.details,
stopped: ce.stopped,
prevented: ce.prevented
});
});
et.fire("frob");
et.after("frob", function (event) {
console.log("I hope I don't miss a frob!", event.target.frobs);
});
et.fire("frob");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment