moxy-community / Moxy

Moxy is MVP library for Android with incremental annotation processor and ktx features
MIT License
327 stars 33 forks source link

Struggles with RxJava and Moxy #122

Closed khoben closed 4 years ago

khoben commented 4 years ago

Sample observable:

Observable.zip(
            frames,
            audio,
            { f, a -> Pair(f, a) }
        ).subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe({ result ->
                callback.invoke(result)
            },{ error ->
                errorListener?.invoke(error)
            })

Callback from it within Moxy ViewPresenter (called from onFirstViewAttach()):

process.onError { error ->
                viewState.onErrorProcess(error)
            }
            .load { result ->
                viewState.onSuccessProcess(result)
            }

viewState.onErrorProcess(error) and viewState.onSuccessProcess(result) will never called cuz if (hasNotView()) { return; } statement tells that view state doesn't have any view. But everything before and after Observable works fine.

My depencies:

kapt "com.github.moxy-community:moxy-compiler:2.2.0"
implementation "com.github.moxy-community:moxy:2.2.0"
implementation "com.github.moxy-community:moxy-app-compat:2.2.0"
implementation 'io.reactivex.rxjava3:rxkotlin:3.0.1' (also had tried with 2.0 version)
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'