11:34
<Andreu Botella>
It looks like there are a few spec-created iterators that use the generators machinery internally
11:36
<Andreu Botella>
currently I think this would only allow observing the AsyncContext generators state if you use Object.defineProperty to make one of the indexes of an array (or maybe also a regex) have a getter
11:36
<Andreu Botella>
const asyncVar = new AsyncContext.Variable();

const array = [23, 34, 45];
Object.defineProperty(array, 1, {
  get() {
    return asyncVar.get();
  }
});

const iter = asyncVar.run("foo", () => array.values());

asyncVar.run("bar", () => {
    console.log([...iter]);  // [23, "foo", 45]
});
11:36
<Andreu Botella>
but this would be more readily observable with iterator helpers
11:40
<Andreu Botella>
const asyncVar = new AsyncContext.Variable();

const array = [23, 34, 45];
const iter1 = array.values();
const iter2 = asyncVar.run("foo", () => {
    return iter1.map(v => [asyncVar.get(), v]);
});
asyncVar.run("bar", () => {
    console.log([...iter2]);  // [["foo", 23], ["foo", 34], ["foo", 45]]
});
11:41
<Andreu Botella>
is this expected?