async tasks with es6 generators

added by JavaScript Kicks
3/27/2015 5:19:51 PM

1 Kicks, 214 Views

ES6 generators seem to be a very good fit for handling asynchronous actions. I've been using a library, generator-runner, which uses ES6 generators for running async tasks. To use the library you create a runner that takes two parameters: A generator function. Within this function you yield to a async task. The async task is invoked with a callback to continue the generator (calling next). The callback returns the value for the yield expression. The runner then takes the value for yield expression and returns it. A callback to handle the return of the generator. The return value from the previous step is handled here.


0 comments