How I can call generator like this:
const scenarioProvider = (function*() {
....
}).bind(this)();
By the arrow function syntax. I mean to replace the 'bind(this)' by the new 'lexical this'.
How I can call generator like this:
const scenarioProvider = (function*() {
....
}).bind(this)();
By the arrow function syntax. I mean to replace the 'bind(this)' by the new 'lexical this'.
This is not currently possible and is not likely to be included in future versions of ecmascript.
Just to let everyone know (meeting notes, coming soon, will make this clear), we agreed not to do generator arrows. Too much trouble of the kind identified here...
source: Brendan Eich @esdiscuss
Arrow functions by definition are lexically scoped. You cannot use a generator with an arrow function
Note however than you cannot bind an arrorw function.
MDN states:
An arrow function expression (also known as fat arrow function) has a shorter syntax compared to function expressions and lexically binds the this value (does not bind its own this, arguments, super, or new.target). Arrow functions are always anonymous.