Find file
Fetching contributors…
Cannot retrieve contributors at this time
18 lines (12 sloc) 599 Bytes
console.log "This file demonstrates how Futures how Futures hold on to the result of the parallel operation until it is requested by their get method. \n"
AsyncFuture = require '../../src/async_future'
delay_function = (delay, done) ->
console.log 'The future receives the result.'
done('result')), delay)
console.log 'creating the future...'
future = new AsyncFuture delay_function, 1000
later_method = ->
console.log 'requesting the result now'
future.get -> console.log "The future calls the get method's callback with the result."
setTimeout later_method, 3000