javascript - LiveScript - How do I use the backcall operator when there are multiple callbacks? -
for example:
$.get('/path/to/api').then( function(data) { alert( "$.get succeeded" ); }, function(error) { alert( "$.get failed!" ); } );
is possible apply backcall operator on both callbacks?
you can use 1 function backcall, can use backcall, , supply other function (note use of _
placeholder denote backcall function should go in arguments) - eg.
data <- $.get '/path/to/api' .then _, -> alert "$.get failed!" alert "$.get succeeded"
compiles to:
$.get('/path/to/api').then(function(data){ return alert("$.get succeeded"); }, function(){ return alert("$.get failed!"); });
Comments
Post a Comment