Hello! Is there a native way to convert Reaktive c...
# reaktive
n
Hello! Is there a native way to convert Reaktive classes into RxSwift?
a
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
Thanks!
o
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
@Omar Mainegra could you share the snippet you have?
o
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
Thanks!
o
NP, I'm not a 100% sure it's the best approach tho, but it's been working for us
a
Thanks for the sample. We are working on the interop, so please stay tuned. I will consider putting some samples meantime.
o
Awesome
a
Thanks @Omar Mainegra for the sample. I added a code snippet to the issue based on this.
o
Very nice, thank you