Package Exports
- toffeescript-coroutines
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (toffeescript-coroutines) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Coroutines in ToffeeScript
A simple coroutine construct over ToffeeScript's Continuation Passing Style Transform
{pause, wait, update} = require 'coroutines.coffee'
setInterval update, 1000 / 60 # run the scheduler
#requestAnimationFrame update
it_pauses = ->
loop
do somethingEveryFrame
pause! # continue in next frame
it_waits = ->
loop
for thing in things
do thing.action
wait! 100 # continue after 100 milliseconds
it_flows = ->
# a coro that can optionally be waited on by another
one = (nxt) ->
wait! 1000
console.log 'one'
nxt?()
two = ->
one! # wait for one to finish
console.log 'two'
do two # after a second, prints "one", then "two"