eo is generator based flow control (like tj/co) and DOM event loop.
eo supports Promise, WHATWG Streams(Readable/Writable) and DOM event(click, touch, etc).
TODO: publish to npmjs.com
basic control flow.
eo(function*(){
console.log('sleep...');
var result = yield sleep(200);
console.log('wake!', result);
return 'finish!';
}).then((val)=>{
console.log(val); // finish!
});
with ReadableStream.
eo(function*(){
var rs = new SampleReadableStream();
var data;
while((data = yield rs) !== eo.EOF) {
console.log('data', data);
}
console.log('finish');
});
with WritableStream.
eo(function*(){
var ws = new SampleWritableStream();
var data = [1, 2, 3, 4, eo.EOF];
for (var chunk of data) {
yield [ws, chunk];
}
console.log('finish');
});
with DOM event.
var click = new eo.DOMEventStream('#box', 'click');
eo.loop(function*(){
var event = yield click;
console.log('event', event);
});
see example
TODO: write document.
MIT