Reason why generators do not have references to themselves?

Domenic Denicola domenic at domenicdenicola.com
Thu Jan 23 16:46:26 PST 2014


Task.js is still on "JavaScript 1.8," and is not ES6-compatible. It won't work with modern browsers, or with Regenerator.

> On Jan 23, 2014, at 19:43, "Brendan Eich" <brendan at mozilla.com> wrote:
> 
> Bradley Meck wrote:
>> Is that true even though then should fire after the generator unwinds its stack?
> 
> True if .then always runs in a later turn -- sorry.
> 
> Still, my point stands: you are not using task.js-like scheduler/combinator approach for an apples-to-apples comparison with await. If you do, then we're down to the obligation of a task.js download, and some syntactic sugar.
> 
> // assume req in scope
> spawn(function*()  {
>  try  {
>    var  session  =  yieldlogin(req);  // wait until the promise resolves
>    gotoProfile(session);
>  }
>  catch  (e)  {
>    printError(e);
>    gotoLogin();
>  }
>  // implicit return undefined
> });
> 
> BTW, in ES7, no "use await"; will be needed ;-).
> 
> If you want to control when the task starts, you'd use new Task. If you want to send req, you'd control starting via t = new Task(function*(){...}) and call t.next(req). Hope this is all clear from http://taskjs.org/ and the code.
> 
>> I am using regenerator right now while playing with this stuff.
> 
> Cool -- can you try task.js?
> 
> /be
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss


More information about the es-discuss mailing list