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

fix(Subject): do not expose static create method to inherited #1894

Closed
wants to merge 1 commit into from

Conversation

kwonoj
Copy link
Member

@kwonoj kwonoj commented Aug 22, 2016

Description:
This PR aligns interface of classes inherited from Subject<T>, do not expose static creation method by introducing abstract class SubjectBase<T>.

Related issue (if exists):

closes #1890

@kwonoj
Copy link
Member Author

kwonoj commented Aug 22, 2016

I'm feeling this might not be correct understanding of removing static interfaces or either incorrect implementation of having abstract classes - please feel freely close if PR is not feasible.

@coveralls
Copy link

coveralls commented Aug 22, 2016

Coverage Status

Coverage increased (+0.0009%) to 97.114% when pulling 13d3358 on kwonoj:fix-subjectcreate into da8c1c2 on ReactiveX:master.

@kwonoj
Copy link
Member Author

kwonoj commented Aug 22, 2016

..Or instead static creation method to comply inherited classes (similar to #1876)

@jayphelps
Copy link
Member

jayphelps commented Aug 22, 2016

As discussed in #1890, there may be merit to adding support for create to other subject types, but in the interest of initial simplicity and correctness I think this is probably the right approach for now. This code looks good, but I'm worried that this is in fact a breaking change.

(new AsyncSubject) instanceof Subject will no longer pass, and that scares me and seems counter-intuitive. I'm probably being alarmist though..but I'm going to let others chime in here please.

@kwonoj
Copy link
Member Author

kwonoj commented Aug 22, 2016

(new AsyncSubject) instanceof Subject will no longer pass, and that scares me and seems counter-intuitive.

: I think that's legit point that I couldn't think of at the moment writing PR. do we have general usecases for checking types of inherited subjects?

@jayphelps
Copy link
Member

jayphelps commented Aug 22, 2016

Not really for instanceof..but I wouldn't be surprised to see it. More commonly I imagine this would bite people with type systems:

class ActionsObservable extends Observable<Action> {
  constructor(source$: Subject<Action>) {
    this.source = source;
  }
}

const source$ = new ReplaySubject<Action>();
const action$ = new ActionsObservable(source$);
// type error: ReplaySubject does not match type Subject

(we do this pattern, but not currently using TypeScript so wouldn't impact us at the moment)

This isn't the end of the world. It's just changing Subject -> SubjectBase obviously. But it's a breaking change.

@kwonoj
Copy link
Member Author

kwonoj commented Aug 22, 2016

gotcha, you're correct. This PR makes breaking change to consumers should accept SubjectBase as base class instead of explicit Subject. Seems change's more broad than I originally expected..

@kwonoj
Copy link
Member Author

kwonoj commented Aug 22, 2016

I tried small snippet here and at least as long as subject does not have it's own instance method type inference will work between subjectbase inherited vs subject itself. But as you've mentioned, I agree this isn't only cases hitting consumers and there might be more cases as well.

My current feeling is rather document Subject.create only works for Subject itself for now until fully resolve static creation method inheritance design and close this PR without merging. what do you think?

@kwonoj kwonoj added the blocked label Aug 22, 2016
@kwonoj
Copy link
Member Author

kwonoj commented Aug 23, 2016

closing PR without check in as intended design is to support create method for all subject implementation.

@kwonoj kwonoj closed this Aug 23, 2016
@kwonoj kwonoj deleted the fix-subjectcreate branch August 23, 2016 05:31
@lock
Copy link

lock bot commented Jun 6, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BehaviorSubject created with "create" does not have getValue() method
3 participants