Skip to content

Instantly share code, notes, and snippets.

@brian428
Created October 3, 2012 05:49
Show Gist options
  • Save brian428/3825275 to your computer and use it in GitHub Desktop.
Save brian428/3825275 to your computer and use it in GitHub Desktop.
# Using a Promise
loadCompanies: ->
@companyService.loadCompanies().then(
success: ( records ) ->
# Do something with results
failure: ( error ) ->
# Do something with the error
).always( ->
# Do something whether the call succeeded or failed
)
# Using a Promise for a chain of async calls
loadInitialData: ->
@companyService.loadInitialData().then(
success: ( records ) ->
# Do something with results
failure: ( error ) ->
# Do something with the error
).always( ->
# Do something whether the call succeeded or failed
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment