Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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