destiny icon indicating copy to clipboard operation
destiny copied to clipboard

Implementation of @@asyncIterator is bad

Open 0kku opened this issue 4 years ago • 0 comments

The current implementation of [Symbol.asyncIterator]() on ReactiveArray and ReactivePrimitive is very sketchy. However, this doesn't seem to be practically fixable until browsers support ReadableStream::getIterator():

  // for ReactiveArray
  async *[Symbol.asyncIterator]() {
    yield* new ReadableStream<[number, number, ...IArrayValueType<InputType>[]]>({
      start: controller => this.#callbacks.add(
        (
          ...args: [number, number, ...IArrayValueType<InputType>[]]
        ) => controller.enqueue(args)
      ),
    }).getIterator();
  }

Depends on:

0kku avatar May 08 '20 15:05 0kku