Closed richytong closed 4 years ago
I like observables. Observables are a tried and true push source (thanks for testing them out so thoroughly), and they are modeled by async iterables. It's only natural that Observable (like a nodejs Stream) implement [Symbol.asyncIterator]
Right now, this is the case
> of(1) Observable { _isScalar: false, _subscribe: [Function (anonymous)] } > of(1)[Symbol.asyncIterator] undefined
A solution I'd like
> of(1) Observable { _isScalar: false, _subscribe: [Function (anonymous)] } > of(1)[Symbol.asyncIterator] [GeneratorFunction] // or any async iterable
You'd be able to use an Observable like
for await (const event of new Observable(...)) { // do stuff with event }
I understand this is perhaps not the way you intended Observables, but @@asyncIterator is part of the ECMA spec now.
I am happy to help / contribute.
https://github.com/ReactiveX/rxjs/pull/5297
I like observables. Observables are a tried and true push source (thanks for testing them out so thoroughly), and they are modeled by async iterables. It's only natural that Observable (like a nodejs Stream) implement [Symbol.asyncIterator]
Right now, this is the case
A solution I'd like
You'd be able to use an Observable like
I understand this is perhaps not the way you intended Observables, but @@asyncIterator is part of the ECMA spec now.
I am happy to help / contribute.