Skip to content

Instantly share code, notes, and snippets.

@jameswomack
Created September 28, 2012 18:19
Show Gist options
  • Save jameswomack/3801364 to your computer and use it in GitHub Desktop.
Save jameswomack/3801364 to your computer and use it in GitHub Desktop.
Call method when n events have fired
Batman.Object::actOnListeners = (context, f, objectEventPairs...) ->
_satisfiedObjects = []
for objectEventPair in objectEventPairs
objectEventPair[0].on objectEventPair[1], ->
_satisfiedObjects.add objectEventPair
f.apply theContext if objectEventPairs.exclude(_satisfiedObjects...).length is 0
@actOnListeners @, @showArticle, [[Brilliant,'ready'],[@get('currentArticleView'),'ready']]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment