Let's assume I have such function (in Javascript):
function fun(success_cb, error_cb) { var result; try { result = function_that_calculates_result(); success_cb(result); } catch (e) { error_cb(e); } }
And I use it like:
fun(function(result) { console.log(result); }, function(error) { console.log(error.message); });
How can I rewrite usage of this function in IcedCoffeeScript with await
and defer
?
From maxtaco/coffee-script#120:
There are two main ways to solve this issue: