从具有ES7异步和异步生成器功能的for ... on循环返回时会发生什么?

时间:2016-02-09 03:45:28

标签: javascript traceur ecmascript-next

我试图围绕以下示例中发生的事情绞尽脑汁:

class Project {
  async foo(input) {
    for (let barOutput on this.bar(input)) {
      // what happens on the following line?
      return barOutput.id;
    }
  }

  async *bar(input) {
    yield {
      id: input.id,
      title: "Test"
    };
  }
}

new Project().foo()
  .then(result => {
    console.log(result);
  });

return循环中的for...of语句是否取消订阅代表Project#bar输出的观察者?

0 个答案:

没有答案