-
Notifications
You must be signed in to change notification settings - Fork 751
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
4.x: Deanonymize operators #549
Conversation
LGTM overall, can you centralize that OnNext-ignoring observer, definitely avoid copy-and-paste, maybe make it an extension for observers? |
Maybe as a separate PR? |
Sure. |
if (Kind == NotificationKind.OnNext) | ||
protected override IDisposable SubscribeCore(IObserver<T> observer) | ||
{ | ||
return scheduler.Schedule(new State { parent = parent, observer = observer }, (scheduler, state) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a ValueTuple e.g. (parent, observer)
@@ -57,22 +121,69 @@ public virtual IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, Tas | |||
|
|||
public virtual IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, CancellationToken, Task<IDisposable>> subscribeAsync) | |||
{ | |||
return new AnonymousObservable<TResult>(observer => | |||
return new CreateWithTaskDisposable<TResult>(subscribeAsync); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code reuse or inheritance or something similar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean? I've mentioned the benefits of these changes in the PR text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean those IObserver-implementors that are duplicated. There is a good chance for code reuse I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which other implementation are you refering to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Func<IObserver<TResult>, CancellationToken, Task<Action>> subscribeAsync
Func<IObserver<TResult>, CancellationToken, Task<IDisposable>> subscribeAsync
Action
!= IDisposable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A common base class might be possible, but nevermind, it's good as it is.
Just one more thing, have you considered using ContinueWith on the Tasks instead of converting them with ToObservable? You can pass it a state and possibly save some allocations. Might as well happen in a future PR. |
Maybe in a later PR, the aim in this PR to avoid those anonymous instances and intermediate delegates. |
This PR factors out the use of
AnonymousObservable
in standard operators for two reasons: