Skip to content

Instantly share code, notes, and snippets.

@reinh
Created November 28, 2012 03:27
Show Gist options
  • Save reinh/4158865 to your computer and use it in GitHub Desktop.
Save reinh/4158865 to your computer and use it in GitHub Desktop.
# Context: a campfire client using ranger (https://github.com/mrduncan/ranger)
# takes a callback function which it passes the messages returned from
# Campfire.
room.recentMessages (messages) -> console.log messages
# takes a user id and a callback function which it passes the user returned
# from Campfire.
client.user userId, (user) -> console.log user
# The problem is that I want to decorate each message with its associated user
# object. If client.user returned the user object directly I could do this:
for message in messages
message.user = client.user message.userId
# How do I do this via callbacks?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment