I donβt think there is an optimal way to do this in ice coffee script, although there are some interesting suggestions in this post: Iced coffee script with several callbacks
I would just stick with a vanilla coffee script:
So your function would be indecent in a coffee script
fun = (success_cb, error_cb) -> try result = function_that_calculates_result() success_cb result catch e error_cb e
and as you might call it in a coffee script
fun (result) -> console.log result , (error) -> console.log error.message
If you can rewrite the fun function in the style of "errback" (err, result) in a coffee script, it will be:
fun = (callback) -> try result = function_that_calculates_result() callback null, result catch e callback e
you would use it just like in frozen coffeescript
await fun defer error, result if error console.log error.message else console.log result
source share