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?
I don't think there is an optimal way to do that in iced coffee script, although that post has some interesting suggestions: Iced coffee script with multiple callbacks
I would just stick to vanilla coffee script:
This is how your function would be writtent in coffee-script
and how you would call it in coffee script
If you can rewrite the fun function in an "errback" style (err, result) in coffee script, that would be:
you would then use it like that in iced coffeescript