https://kotlinlang.org logo
#reaktive
Title
# reaktive
n

Nikita Khlebushkin

11/02/2020, 10:27 AM
Hello! Is there a native way to convert Reaktive classes into RxSwift?
a

Arkadii Ivanov

11/02/2020, 10:57 AM
Hello! There is no "official" solution currently, but there is an open issue: https://github.com/badoo/Reaktive/issues/538 So for now it is advisable to implement interop on your own. It should be quite straightforward.
n

Nikita Khlebushkin

11/02/2020, 12:00 PM
Thanks!
o

Omar Mainegra

11/03/2020, 2:44 PM
Maybe it's a good idea to provide a code snippet, even if it has to be copied manually on every project, I have one but I'm not even sure it's the correct approach
n

Nikita Khlebushkin

11/03/2020, 2:57 PM
@Omar Mainegra could you share the snippet you have?
o

Omar Mainegra

11/03/2020, 2:57 PM
For sure
Copy code
extension Observable where Element: AnyObject {
    static func from(_ reaktiveObs: ReaktiveObservableWrapper<Element>) -> Observable<Element> {
        return Observable<Element>.create { observer in
            let disposable = reaktiveObs.subscribe(
                isThreadLocal: false,
                onError: { error in observer.onError(ReaktiveError(throwable: error)) },
                onComplete: { observer.onCompleted() },
                onNext: { value in observer.onNext(value) }
            )

            return Disposables.create { disposable.dispose() }
        }
    }
}
n

Nikita Khlebushkin

11/03/2020, 2:58 PM
Thanks!
o

Omar Mainegra

11/03/2020, 2:59 PM
NP, I'm not a 100% sure it's the best approach tho, but it's been working for us
a

Arkadii Ivanov

11/03/2020, 3:05 PM
Thanks for the sample. We are working on the interop, so please stay tuned. I will consider putting some samples meantime.
o

Omar Mainegra

11/03/2020, 4:56 PM
Awesome
a

Arkadii Ivanov

11/04/2020, 9:43 PM
Thanks @Omar Mainegra for the sample. I added a code snippet to the issue based on this.
o

Omar Mainegra

11/04/2020, 10:01 PM
Very nice, thank you
12 Views