Permalink
Browse files

add Component#emitDelayable

  • Loading branch information...
1 parent f62b4b9 commit d045127e254c26f309de413fadbfa3fec7ce6d21 @nateps nateps committed Jul 29, 2012
Showing with 15 additions and 0 deletions.
  1. +15 −0 lib/component.js
View
@@ -29,6 +29,21 @@ componentProto.emitCancellable = function() {
return cancelled;
};
+componentProto.emitDelayable = function() {
+ var delayed = false
+ , args = arraySlice.call(arguments, 0, -1)
+ , callback = arguments[arguments.length - 1]
+
+ function delay() {
+ delayed = true;
+ }
+
+ args.push(delay, callback);
+ this.emit.apply(this, args);
+ if (!delayed) callback();
+ return delayed;
+};
+
function type(view) {
return view === this.view ? 'lib:' + this.id : this.ns + ':' + this.id;

0 comments on commit d045127

Please sign in to comment.