Created
June 12, 2013 07:46
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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