Subscribing to an observable that is function of another observable #1948
Unanswered
martinrhan
asked this question in
Q&A
Replies: 1 comment
-
Exists an operator that does exactly what you ask: Switch.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have an
IObservable<TypeA>
instance. There is a functionpublic static IObservable<TypeB> MyFunction(TypeA a)
.Now I want to subscribe to theIObservable<TypeB>
object returned fromMyFunction(currentTypeAObject)
, but when theIObservable<TypeA>
has a change, the previous subscription of theTypeB
object is disposed and a new subscription to whats returned byMyFunction(newTypeAObject)
is established.Whats decribed above is actually a generalization of a common scenario in UI development, that is, subscribing to a nested property, for example, given
objectA
, subscribeobjectA.TypeAPropertyA.TypeBPropertyB
. Existing frameworks somehow provide capability to subscribe the entire path, in which any part of the chain changes result into a notify to the subsribers and internal modifications of subscription states. However, they are limited and not generalized. For instance, ReactiveUI only support binding path that all parts are properties.I would like to know if there is an elegant and swift solution for this, using existing classes in reactive extensions.
Beta Was this translation helpful? Give feedback.
All reactions