Closed lolive closed 10 years ago
According to this.. http://stackoverflow.com/questions/18293563/can-node-fibers-be-implemented-using-es6-generators and this... http://calculist.org/blog/2011/12/14/why-coroutines-wont-work-on-the-web/ it doesn't look good.
It didn't looked good, but it went much better than expected!
Now, the answer is YES.
I'm about to upload a version of _wait.for_ based on the upcoming ES6 Generators. The funny thing is, the implementation of the core function _wait.for(async,arg...)_, using ES6 generators is:
wait.for = function( asyncFn ) { return arguments; }
Yes, just return arguments.
You use _wait.for inside a generator (function) in conjunction with new JS/ES6 _yield* keyword, as in:
var data = yield wait.for ( fs.readFile, '/etc/somefile' );
Sequential programming for node.js _and the browser_, end of callback hell.
Great news!
I'm wondering if waitfor can detect if ES6 is available, and load the correct implementation. That would be nice, but do you agree that it's a good idea?
Thanks for this project. I am very pleased that Exceptions can actually be used!
The ES6-generators impose on the programmer NEW SYNTAX (a mistake in my opinion).
Instead of being able to launch any function as a generator, you need to use a MODIFIED keyword funcion: "function*" (note the asterisk), and you can only use 'yield' inside such functions. So, they're adding two new keywords, and altering "function" instead of adding functionality as core objects and functions.
Because of that, 'waitfor-ES6' does the same as 'waitfor' -BUT- is forced to use 'function*' and 'yield'. The conversion is easy, but you cannot use exactly the same code with both libs.
On Tue, Sep 3, 2013 at 7:22 AM, Callan Bryant notifications@github.comwrote:
Great news!
I'm wondering if waitfor can detect if ES6 is available, and load the correct implementation. That would be nice, but do you agree that it's a good idea?
Thanks for this project. I am very pleased that Exceptions can actually be used!
— Reply to this email directly or view it on GitHubhttps://github.com/luciotato/waitfor/issues/3#issuecomment-23702467 .
Can we expect Wait.for to run on any browser any time soon? For example when all the major players embrace the latest ECMAScript specifications. Your comment is welcome.