tc39 / proposal-observable

Observables for ECMAScript
https://tc39.github.io/proposal-observable/
3.06k stars 90 forks source link

Are observables (async) iterables? #116

Closed mohsen1 closed 7 years ago

mohsen1 commented 7 years ago

If observables are behaing this much like iterables (done, next, map, etc) doesn't it make sense to make them actually an iterable that return a promise on each iteration?

const obs = Observable.of(
  Promise.resolve("red"),
  Promise.resolve("green"),
  Promise.resolve("blue")
);
for (const o of obs) {
   console.log(await o);
}
RangerMauve commented 7 years ago

There is already an async iterator proposal. Also, Observables aren't meant to necessarily be asynchronous. As well, it has been brought up that Promises will incur more of a performance hit than the current method.

mohsen1 commented 7 years ago

Thanks @RangerMauve!

RangerMauve commented 7 years ago

@mohsen1 You might also be interested in this issue: #111