Closed psxcode closed 6 years ago
That's an awesome idea!
It's a nice concept, so nice in fact that's how we started several years ago 😆
If you look at the first iterations of this proposal this is how they worked. @jhusain has a talk about it.
The problem is that people found it confusing at the end of the day.
That's the interface that we started with, but we ran into trouble with the semantics of return
. For generators, we expect return
to be called on both completion and cancellation, because return
has cleanup semantics (it allows a generator function to execute finally blocks). But for Observable, we did not want to conflate cancellation with completion.
There were some other concerns as well.
Eventually, we were content with the fact that it is easy to adapt a generator object (or generator function) to an observer.
Generators can be used as
Generator object interface
This will allow to use Generators as consumers of Observable stream