-
Notifications
You must be signed in to change notification settings - Fork 3k
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
refactor(Observable): Make 'protected' of Observable<T>._isScalar #522
Conversation
This property should be accessed only from a derived class.
LGTM |
I'm uncertain about this one... only because there are places where we're checking |
...meaning, if we ever decided to use proper typing in those points (and I'm not sure why we would, since they're internal to the library and not public APIs), having this as Is there a reason why we want this change? |
Without this change, |
@saneyuki it's perfectly acceptable to override |
Yes, I don't think it's problem to override I feel it is reasonable idea to define a |
@saneyuki .... I think my concern is that we access it "publicly" internally and I don't want to have TypeScript complaining at us or need to have to cast something as |
Sorry, @saneyuki, I think for now I'm going to close this PR. While it doesn't break anything, I'm not sure it fixes anything either. A third party may want to create a custom operator that optimizes for scalar observables which means checking _isScalar. I really appreciate the thought and effort you've put into this. I'm just not sure it's the right move at this point. ... if we end up doing this later, you can totally say "I told you so" :) |
Then, they uses/extends |
PromiseObservable can also be _isScalar |
Ah, my words is too short. My intent of the previous reply is that: A third party who want to create a custom operator for them can check whether scalar/promise observable by using I think basically we should not make public of internal items until if we meet unavoidable to expose them. I'm worrying it would be harder to stop exposed internals in early stage. |
Since PromiseObservable can be optimized as "scalar" with However, maybe we can have PromiseObservable extend ScalarObservable... I don't know, I haven't put much thought into it. |
... probably not though. |
This (specialized) pass would work as instanceof checking. if (observable instanceof ScalarObservable || observable instanceof PromiseObservable) {
...
} |
...I meant it on my replying. |
I'll investigate it. I don't want to make this change right now. Other things would need to change. For example, you can't treat PromiseObservables the same as scalars until they've resolved once... so it would be more like: if (observable instanceof ScalarObservable || (observable instanceof PromiseObservable && observable.isResolved)) {
...
} I'm unsure if that's going to be more efficient than just checking Also, we'd have to publish |
Okay. I accept your decision. Thank you for a long discussion. |
<3 @saneyuki |
This property should be accessed only from a derived class. There's no need to make this public.