lambda
lambda copied to clipboard
Promises and asynchronous functions
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