Skip to content

Instantly share code, notes, and snippets.

@brian428
Created October 3, 2012 05:48
Show Gist options
  • Save brian428/3825270 to your computer and use it in GitHub Desktop.
Save brian428/3825270 to your computer and use it in GitHub Desktop.
# Common way of making async call via underlying Store
loadCompanies: ->
@companyService.loadCompanies(
callback: ( records, operation, success ) ->
if( success )
# Do something with results
else
# Do something with the error
# Do something whether the call succeeded or failed
)
# Common way of making async call via underlying Ext.Ajax call
loadCompanies: ->
@companyService.loadCompanies(
success: ( response ) ->
results = Ext.decode( response.responseText )
# Do something with results
# Do something whether the call succeeded or failed
failure: ( response ) ->
# Do something with the error
# Do something whether the call succeeded or failed
)
# Ill-advised attempt to make a chain of async call via underlying Store
loadInitialData: ->
@companyService.loadCompanies(
callback: ( companyRecords, operation, success ) ->
if( success )
@companyService.loadFeaturedProducts(
callback: ( productRecords, operation, success ) ->
if( success )
# Do something with both sets of results
else
# Do something with the error
# Do something whether both calls succeeded or failed
)
else
# Do something with the error
# Do something whether both calls succeeded or failed
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment