Created
July 19, 2012 00:00
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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