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

Methods that accept Observable could accept anything Observable.from does #44

Closed
benlesh opened this issue Aug 11, 2023 · 4 comments
Closed
Assignees

Comments

@benlesh
Copy link
Collaborator

benlesh commented Aug 11, 2023

Given there's an issue to possibly add Observable.from to this API #28, and I think that's a good add, it's worth mentioning that in RxJS anywhere we accept an Observable we also accept anything that Observable.from would accept.

This is stemming from my comment about takeUntil here.

Basically anywhere we accept an Observable or a function returns an Observable that the functionality is processing (takeUntil or flatMap for example), it's totally fine to also allow anything that Observable.from could accept and just do that conversion for the user. It cleans up a lot of code to allow this.

@ljharb
Copy link

ljharb commented Aug 11, 2023

Generally the purpose of a .from method is to prevent that overloading - meaning, that users are forced to do the nice, explicit thing, and ensure they have a real Observable before using them as such.

Obviously any method could accept both sets of inputs by wrapping the observable-ish in Observable.from but I would not expect builtin methods to do that.

@domenic
Copy link
Collaborator

domenic commented Aug 11, 2023

Built-in methods accepting anything that can be converted is a common pattern on both the web platform and JS built-ins. +1 to this idea.

@ljharb
Copy link

ljharb commented Aug 11, 2023

Ah, as an argument, that's true - but not as a receiver.

@domfarolino
Copy link
Collaborator

Closed by #60.

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

4 participants