Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Subject.create vs AnonymousSubject.create #2004

Closed
benlesh opened this issue Oct 4, 2016 · 2 comments
Closed

Subject.create vs AnonymousSubject.create #2004

benlesh opened this issue Oct 4, 2016 · 2 comments

Comments

@benlesh
Copy link
Member

benlesh commented Oct 4, 2016

Related #2002, #2003, #1996, #1975

Currently, Subject.create is built to mimic it's behavior in v4 and under. That is that Subject.create actually returns an AnonymousSubject, and not a Subject.

Problem

  • This flies in the face of other uses of create in this library, which is as an alternative to new... for example: new Observable(fn) vs Observable.create(fn). This creates confusion for users (and experts, apparently)
  • We can't move AnonymousSubject into it's own module, because there would be a circular reference with Subject, which has this create method that only creates an AnonymousSubject.

Proposal:

  • Subject.create becomes alternative version of new Subject
  • AnonymousSubject.create does what Subject.create does now... which is just an alternative version to new AnonymousSubject.
  • move AnonymousSubject to it's own module.
@reduckted
Copy link

This is really confusing behaviour. I figured, since new Observable() and Observable.create() are basically the same, that new Subject() and Subject.create() would also be the same. How wrong I was!

@zoechi
Copy link

zoechi commented Nov 15, 2020

#2002 was merged but that doesn't make AnonymousSubject public. For this it would need to be listed here as well https://github.com/ReactiveX/rxjs/blob/master/src/index.ts#L10.
Also new AnonymouseSubject(...) supports a destination and source parameter, while new Subject() or Subject.create() do not. Some comment on how to translate would be great when one is deprecated.

@benlesh benlesh closed this as completed May 4, 2021
@ReactiveX ReactiveX locked and limited conversation to collaborators May 4, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants