Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # async calls sequentalization
- apply = (f, s) -> () -> f( () -> s() )
- id = (args...) -> args
- foldr = (f, z, [x, xs...]) -> if x then f x, (foldr f, z, xs) else z
- chain = (funcs...) -> (foldr apply, id, funcs)()
- action1 = (done) ->
- async_action_with_callback(done)
- action2 = (done) ->
- async_action_with_callback(done)
- # ...
- actionN = (done) ->
- async_action_with_callback(done)
- chain action1, action2, ..., actionN
Add Comment
Please, Sign In to add comment