Hello everyone, I'm using RxSwift in my iOS app an...
# rx
p
Hello everyone, I'm using RxSwift in my iOS app and now I want to use RxKotlin in my Android app, but one question, with RxSwift you can create a
Variable
to access to the current value (
myVar.value
) and if you want you can create an observable (
myVar.toObservable
). There is a way to do that with RxKotlin ?
g
RxKotlin is just collection of extensions and builders for RxJava - https://github.com/ReactiveX/RxJava Don’t understand your question tho, maybe you clarify it with example
http://reactivex.io/ - also you can try to find examples of different operators for different Reactive extensions, including RxSwift
e
I think you mean
BehaviorSubject.createDefault(myVar)
RxJava does not have such thing as
Variable
, the similar thing should be
BehaviorSubject
p
With RxSwift we have : • BehaviorSubject: Starts with an initial value and replays it or the latest element to new subscribers. • Variable: Wraps a BehaviorSubject, preserves its current value as state, and replays only the latest/initial value to new subscribers. Maybe it doesn't exist for RxJava/RxKotlin.
e
Variable
does not exist in RxJava/Kotlin, but
BehaaviorSubject
just lacks the ability to replay the initial value? I can't think of any case that you need the initial value when you have a more updated value...
p
Yes you can replay the value with the
BehaaviorSubject
. But
Variable
is useful in some case because : - You can't emit error. - You don't use onNext. - You set directly the value property. - Automatically complete when it’s about to be deallocated. I can do the job with the BehaviourSubject. Thank you for your help !