Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with Observable without Observer: multicasting/Subjects #42

Closed
benlesh opened this issue Jul 13, 2015 · 2 comments
Closed

Problems with Observable without Observer: multicasting/Subjects #42

benlesh opened this issue Jul 13, 2015 · 2 comments

Comments

@benlesh
Copy link

benlesh commented Jul 13, 2015

I realize Subject is not a party of this spec, but it is a part of the Observable ecosystem.

If there are no Observers, what is a Subject? How can a Subject subscribe to an Observable? I suppose it can be done with closures, but that sort of breaks Subject.

@benjamingr
Copy link

How do you feel about #41 (comment) ?

Copying over:


Hmm, I'm starting to like the original better:

  • we have .forEach for iteration, it takes a callback and returns a promise for completion. Maybe it should be renamed as it doesn't indicate (unlike C#) that it creates a subscription and "fires the action". (Maybe .run or .consume or something like that).
  • we have observers for subscribe, these return subscriptions too. This means subjects (which I also use a lot in RxJS) are easy and a straightforward subtype.

Calling things generators or generator return results was super confusing, it took me at least a day to see @jhusain 's point about duality, it is beautiful but it will be very confusing for new users to see generators as both ends of the pipe. It took me a while to see he was doing this thing, it will likely take average users as long as me.

I'm wondering if we can keep next/done/return as a signature but not claim duality, not say a word about generators and just call the next/done/return signature with no return types "observer". We can then claim a generator return result is both the subtype of a regular iteration result and a subtype of an observer which is nice from a "type system point of view". People who explicitly want to "prime" will be able to, but it won't be advertised at the spec level.

This sounds like the best of all worlds.

It's much closer to the original design.


I think that the return value of forEach and subscribe can be unified into a subscription-promise being that doesn't use promise cancellation but is observable-cancellable. Cancellation can be synchronous (not sure why not anyway) with sound semantics.

This has added benefits like subscribe being awaitable, forEach returning a cancellable entity and so on.

@zenparsing
Copy link
Member

Closing since we have Observer again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants