Permalink
Browse files

used for...in loop in coffeescript instead of underscore each()

  • Loading branch information...
1 parent 2bc09c1 commit 1b3f60009ad56be1442deb02dbc2959e28cb8b90 Maurice Fonk committed Dec 27, 2010
Showing with 7 additions and 5 deletions.
  1. +7 −5 lib/MessageRouter.coffee
View
@@ -16,7 +16,7 @@ class MessageRouter
@actions = {}
# "Main" message handler, will match the action list
- client.addListener 'message', _.bind @onMessage, this
+ @client.addListener 'message', _.bind @onMessage, this
# Add a handler to the message router
addHandler: (match, callback, scope) ->
@@ -33,10 +33,12 @@ class MessageRouter
# Message handler
onMessage: (from, to, message) ->
- _.each @actions, (callbacks, match) ->
- if message.match match
- _.each callbacks, (callback) ->
- callback from, to, message
+ for match, callbacks in @actions
+ do (callbacks, match) ->
+ if message.match match
+ for callback in callbacks
+ do (callback) ->
+ callback from, to, message
# Export the messager outer
module.exports = MessageRouter

0 comments on commit 1b3f600

Please sign in to comment.