-
Notifications
You must be signed in to change notification settings - Fork 770
Add the Append and Prepend operator #567
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
Conversation
Thanks. I will happily merge all these new operators once I get a direction on those kind of changes from @onovotny or @ghuntley. Or maybe there is already a roadmap and I missed it?? @quinmars This is perfectly fine to get the operators into Rx. Do you think you could, at some point, provide optimized versions of them that implement the logic directly instead of combining Concat and Return? |
I definately thought about adding an improved version. We will see how far I will get. Maybe I'll need your help at some point. With that in mind, it would probably be better to use |
Sure, just give me a hint if you need help! |
This one is easy, just create a plain forwarding operator and in its |
@akarnokd Thanks, indeed, appending and probably also prepending doesn't look to be terribley complicated. |
If you had fun implementing Prepend, you could take a look at StartWith, which is currently also implemented like this:
There's definitely room for improvement. |
I now added the corresponding Would do you think is the "right" or best behavior of
|
@danielcweber Yes, I'll take a look on it once |
Where is the combination of Return + Concat used currently? |
@danielcweber No where. Except in |
Then you should go with the StartWith-behaviour. Also, why shouldn't Prepend become a special overload of StartWith? Where does the name Prepend come from? |
See #420, |
I'd be careful with this. Concat uses the quite complicated |
@akarnokd Carefull with what? Optimizing |
Yes. |
@akarnokd That's the last point on my list. And if it gets to complicated for me, I'll happily leave it up to you both. :) |
So, I changed the |
BTW, |
# Conflicts: # Rx.NET/Source/src/System.Reactive/Linq/Qbservable.Generated.cs
I could merge it now to have a reference implementation and working tests. You can go either way, if you remove the WIP-tag, I'll merge it. |
…the behavior on unfinished dispose.
This PR will add the Rx counter parts to the
IEnumerable
operatorsAppend
andPrepend
, see #420. It's still work in progress, because there are some open questions.As said in Add Prepend and Append to Rx #420 I prefer to mirror the API of the
IEnumerable
operators exactly, i.e., not the variadic form. But if you favor the variadic form I can also implement that one.Currently, I've implemented it with
source.Concat(Observable.Return(value, scheduler))
, but the results are slightly different tosource.Concat(new[] { value }.ToObservable(scheduler))
. Using the test scheduler theOnComplete
will come at the same tick like the value (see the unit test). In the second case it comes one tick after the lastOnNext
. I don't have a deep knowlege of the schedulers and which variant is more reasonable. The second variant is very similar toStartWith
and how a n-ary append, would be implemented.Right now there is only the code for the append operator. Once the two questions are answered I'll add the prepend operator.