lambda icon indicating copy to clipboard operation
lambda copied to clipboard

Promises and asynchronous functions

Open 71104 opened this issue 8 years ago • 0 comments

They are one honking great idea!

Promises will be available as soon as #65 is fixed because the Promise class can be unmarshalled from the underlying platform normally.

So this bug is mostly about implementing the await statement. E.g.:

let timeout = fn delay ->
  new Promise fn resolve, reject ->
    setTimeout (fn _ -> resolve "hello!") delay in

console.log (await (timeout 1000))  # prints "hello!" after 1 second

71104 avatar Jun 25 '16 13:06 71104