this value inside anonymous generator

Niloy Mondal niloy.mondal84 at
Tue Mar 31 06:38:38 UTC 2015

I wrote some code like the following in tracuer

class Foo {
  constructor() {
    spawn(function*() {
      let data = yield this.fetchData(); // error because 'this' is

  fetchData() {
    // returns promise

I used the spawn function from here:

The code doesn't work because 'this' is undefined. I can fix it by using
'let that = this' pattern. But it feels like a step backward now that I've
fallen in love with lambda functions. So I was wondering if it would be
possible to use lexical binding for 'this' inside anonymous generators.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list