Skip to content

Instantly share code, notes, and snippets.

@mariussoutier
Created June 12, 2013 07:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariussoutier/5763505 to your computer and use it in GitHub Desktop.
Save mariussoutier/5763505 to your computer and use it in GitHub Desktop.
Different ways of calling functions with call-backs (i.e. multiple parameters that are functions) in CoffeeScript.
# Separate functions
success = (data, status, header) ->
promise.resolve data.user
error = (data, status, header) ->
promise.reject data.error
user = getUserById id, success, error
# Comma in front of each function
user = getUserById id
, (data, status, header) ->
promise.resolve data.user
, (data, status, header) ->
promise.reject data.error
# One comma after value parameter
user = getUserById id,
(data, status, header) ->
promise.resolve data.user
(data, status, header) ->
promise.reject data.error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment