destiny
destiny copied to clipboard
Implementation of @@asyncIterator is bad
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:
- ❌Firefox support — P3 😢
- ❌Chromium support — P3 😢
- ❌Webkit support — P2 🙁