this value inside anonymous generator

2015-03-31 Thread Niloy Mondal
I wrote some code like the following in tracuer ``` class Foo { constructor() { spawn(function*() { let data = yield this.fetchData(); // error because 'this' is undefined }); } fetchData() { // returns promise } } ``` I used the spawn function from here:

Re: this value inside anonymous generator

2015-03-31 Thread Jordan Harband
Can you not just use .bind here? ``` spawn(function* () { let data = yield this.fetchData(); }.bind(this)); ``` On Mon, Mar 30, 2015 at 11:38 PM, Niloy Mondal niloy.monda...@gmail.com wrote: I wrote some code like the following in tracuer ``` class Foo { constructor() {

Re: this value inside anonymous generator

2015-03-31 Thread Leon Arnott
Some [old TC39 notes]( https://github.com/rwaldron/tc39-notes/blob/c61f48cea5f2339a1ec65ca89827c8cff170779b/es6/2013-11/nov-20.md#410-generator-arrow-function-syntax) talk about the possibility of generator arrows, and discarded them in ES6 for what was basically a syntactic quandry. (I personally

Re: this value inside anonymous generator

2015-03-31 Thread Kevin Smith
Generator arrows are a possibility, but we need to see how the use cases develop in practice. For the specific use case in the OP, async arrows would actually be a better fit. ___ es-discuss mailing list es-discuss@mozilla.org