-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Operator: Do #40
Comments
was trying to implement this. but since |
I don't see how we would have all 3 of For the method name, I wish Options I can think of are:
This should be easy to implement using I believe the method signatures will end up looking like this ... once we figure out the name: Observable<T> nameOfFunction(Observable<T> source, Action1<T> onNext)
Observable<T> nameOfFunction(Observable<T> source, Observer<T> observer)
Observable<T> nameOfFunction(Observable<T> source, Action1<T> onNext, Action onCompleted)
Observable<T> nameOfFunction(Observable<T> source, Action1<T> onNext, Action1<Exception> onError)
Observable<T> nameOfFunction(Observable<T> source, Action1<T> onNext, Action1<Exception> onError, Action onCompleted) |
Does this function allow modifying the values or does it always return the exact same Observable source? In other words, is this only for performing side-effects? |
I think a function name with Yes it can be easily implemented using Some info on rx do: http://stackoverflow.com/q/8732001/157260 |
|
Generally operators in a sequence do execute each time they are subscribed to - unless something like publish, multicast, replay etc caches the results of a subscription and becomes the source of a new sequence. The documentation I've read is very unclear regarding For example: def o = anObservable
.take(5)
.map({transformHere}}
.merge(anotherObservable)
.do({doSideEffectsHere})
// subscribe to it once
o.subscribe()
// then subscribe again with another transformation done
o.map({anotherTransformation}).subscribe() With sequence
The code above adds Here is the .Net code for I'm not experienced with C# so can't guarantee I understand it but I see nothing in that code that automatically is caching the sequence. Thus, I think the Am I misunderstanding something about the contract specified by Rx.Net? |
@prabirshrestha It makes sense to keep the do* prefix, so what do you prefer of these?
Is there a better option? I lean towards |
@benjchristensen Even I preferred
Thats right. I will verify this with .net too. @mva Observable.FromEvent<TextChangedEventArgs>(searchTextBox, "TextChanged")
.Select(e => ((TextBox)e.Sender).Text)
.Where(text => text.Length > 2)
.Do(s => searchResults.Opacity = 0.5) // reduce list opacity when typing
.Throttle(TimeSpan.FromMilliseconds(400))
.ObserveOnDispatcher()
.Do(s => LoadingIndicator.Visibility = Visibility.Visible) // show the loading indicator
.SelectMany(txt => searchTwitter(txt))
.Select(searchRes => ParseTwitterSearch(searchRes))
.ObserveOnDispatcher()
.Do(s => LoadingIndicator.Visibility = Visibility.Collapsed) // hide the loading indicator
.Do(s => searchResults.Opacity = 1) // return the list opacity to one
.Subscribe(tweets => searchResults.ItemsSource = tweets); I found using |
@benjchristensen, I think I am starting to understand the distinction you are making. The side-effect of a Using logging as an example: this makes perfect sense for a cold/passive observable because every value send to a subscriber is independent of all other values, and deserves its own log entry. On the other hand, if I want to log the output of a hot/active observable irregardless of the (possibly zero) number of subscribers, I would put the Thank you for your explanation! |
http://msdn.microsoft.com/en-us/library/hh229804(v=vs.103).aspx
http://msdn.microsoft.com/en-us/library/hh229307(v=vs.103).aspx
http://msdn.microsoft.com/en-us/library/hh229659(v=vs.103).aspx
http://msdn.microsoft.com/en-us/library/hh229539(v=vs.103).aspx
http://msdn.microsoft.com/en-us/library/hh229830(v=vs.103).aspx
The text was updated successfully, but these errors were encountered: