Created
September 10, 2012 17:29
-
-
Save rhysbrettbowen/3692331 to your computer and use it in GitHub Desktop.
Bound event object
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
var bound = goog.events.listen(src, type, function); | |
// should dispatch event of type on provided targets (or else the src) | |
bound.fire([optional_targets]); | |
// will call unbind the event | |
bound.unlisten(); | |
// can do things like: | |
var bound = goog.events.listen(src, type, function).fire(); | |
// so you can run a function | |
// bound object should have fire, unlisted and the id available and look something like: | |
{ | |
type: [types], | |
id: id_returned_by_goog_events_listen, | |
src: the_source, | |
fn: the function, | |
capture: true_false, | |
handler: context_for_fn, | |
fire: function(opt_targets) { | |
goog.array.forEach(types, function(type) { | |
var target = this.src; | |
if (opt_targets) | |
target = opt_targets; | |
if (!goog.isArray(opt_targets)) | |
target = [opt_targets]; | |
goog.array.forEach(target, function(src) { | |
src.dispatchEvent(type); | |
}); | |
}; | |
}, | |
unlisten: function() { | |
goog.events.unlistenByKey(this.id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment