Closed jandppw closed 9 years ago
@jandppw This is indeed valid code in ES6, which is the only place generators are usable. Did you try running a generator with when/generate
? It works quite well :)
Specifically:
The this
is a generator iterator. The code arranges for the error
function to be called with the proper thisArg--specifically when.js's internal chain
method being used on that line will arrange for iterator
to be the thisArg when either next
or error
is called.
All ES6 generator iterators have a throw
method which sends an error back into the suspended generator.
ES5 allows keywords as property names, thus throw
is a valid property name in all >= ES5 code. Since generators are ES6 only, throw
is a valid property name anywhere you'd be using when/generate
.
Generators and Promises are awesome together. Hope that helps.
Brain,
Thx for the detailed answer!
The report was triggered by an error reported by the Closure compiler, trying to do a dojo build that includes wire
, and thus when
and meld
.
A workaround was to mark the generator
as copyOnly.
Sadly, the build doesn't work, but that's a different issue ...
this.throw(e)
cannot be right. I have no idea what the intention is, butthrow
on any this