Coder Social home page Coder Social logo

Comments (17)

drbear95 avatar drbear95 commented on August 25, 2024 3

What is the status of this case?

from mosby.

ValeriusGC avatar ValeriusGC commented on August 25, 2024

Here is the change i made to fix this problem:
MviBasePresenter.java

        Subject<I> intentRelay = ReplaySubject.create();
        //Subject<I> intentRelay = UnicastSubject.create();

this was inserted on 513d1e9 ("use unicast subject", 2018-04-08)

from mosby.

sockeqwe avatar sockeqwe commented on August 25, 2024

Sorry for the long delay. I'm quite busy at the moment, I will take a look at this at the end of July.
As far as I can tell is that all automated tests (testing Mosby internals) are passing. Hence (without having investigated into this bug) I have the feeling that this is a Sample App issue.

from mosby.

p8499 avatar p8499 commented on August 25, 2024

When I upgrade mosby library from 3.1.0 to 3.1.1 I faced with this problem too.

from mosby.

p8499 avatar p8499 commented on August 25, 2024

Maybe UnicastSubject conflicts with the navigation feature,
stateObservable.share().map{...}.addTo(compositeDisposable)
thus makes it subscribed by two observables.

from mosby.

drbear95 avatar drbear95 commented on August 25, 2024

Im facing this problem in my app, i tried with ReplaySubject but it doesn't work.

from mosby.

sockeqwe avatar sockeqwe commented on August 25, 2024

from mosby.

drbear95 avatar drbear95 commented on August 25, 2024

Here is my stack trace

 java.lang.IllegalStateException: ViewState observable must not reach error state - onError()
        at com.hannesdorfmann.mosby3.mvi.DisposableViewStateObserver.onError(DisposableViewStateObserver.java:22)
        at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.checkTerminated(ObservableObserveOn.java:281)
        at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:172)
        at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:255)
        at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:119)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5221)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
     Caused by: java.lang.IllegalStateException: Only a single observer allowed.
        at io.reactivex.subjects.UnicastSubject.subscribeActual(UnicastSubject.java:311)
        at io.reactivex.Observable.subscribe(Observable.java:12090)
        at io.reactivex.internal.operators.observable.ObservableDoOnEach.subscribeActual(ObservableDoOnEach.java:42)
        at io.reactivex.Observable.subscribe(Observable.java:12090)
        at io.reactivex.internal.operators.observable.ObservableSwitchMap.subscribeActual(ObservableSwitchMap.java:51)
        at io.reactivex.Observable.subscribe(Observable.java:12090)
        at io.reactivex.internal.operators.observable.ObservableMap.subscribeActual(ObservableMap.java:32)
        at io.reactivex.Observable.subscribe(Observable.java:12090)
        at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.subscribeInner(ObservableFlatMap.java:165)
        at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.onNext(ObservableFlatMap.java:139)
        at io.reactivex.internal.operators.observable.ObservableFromArray$FromArrayDisposable.run(ObservableFromArray.java:108)
        at io.reactivex.internal.operators.observable.ObservableFromArray.subscribeActual(ObservableFromArray.java:37)
        at io.reactivex.Observable.subscribe(Observable.java:12090)
        at io.reactivex.internal.operators.observable.ObservableFlatMap.subscribeActual(ObservableFlatMap.java:55)
        at io.reactivex.Observable.subscribe(Observable.java:12090)
        at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.subscribeInner(ObservableFlatMap.java:165)
        at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.onNext(ObservableFlatMap.java:139)
        at io.reactivex.internal.operators.observable.ObservableFromArray$FromArrayDisposable.run(ObservableFromArray.java:108)
        at io.reactivex.internal.operators.observable.ObservableFromArray.subscribeActual(ObservableFromArray.java:37)
        at io.reactivex.Observable.subscribe(Observable.java:12090)
        at io.reactivex.internal.operators.observable.ObservableFlatMap.subscribeActual(ObservableFlatMap.java:55)
        at io.reactivex.Observable.subscribe(Observable.java:12090)
        at io.reactivex.internal.operators.observable.ObservableDoOnEach.subscribeActual(ObservableDoOnEach.java:42)
        at io.reactivex.Observable.subscribe(Observable.java:12090)
        at io.reactivex.internal.operators.observable.ObservableScanSeed.subscribeActual(ObservableScanSeed.java:47)
        at io.reactivex.Observable.subscribe(Observable.java:12090)
        at io.reactivex.internal.operators.observable.ObservableDoOnEach.subscribeActual(ObservableDoOnEach.java:42)
        at io.reactivex.Observable.subscribe(Observable.java:12090)
        at io.reactivex.internal.operators.observable.ObservableDistinctUntilChanged.subscribeActual(ObservableDistinctUntilChanged.java:35)
        at io.reactivex.Observable.subscribe(Observable.java:12090)

And here is my base presenter class

abstract class BasePresenter<TView : BaseView<TViewState>, TViewState: ViewState>(viewState: TViewState)
    : MviBasePresenter<TView, TViewState>(viewState) {

    protected val initialState: TViewState = viewState
    private var viewStateSnapshot: TViewState = viewState

    protected val lastViewState: TViewState
        get() = viewStateSnapshot

    override fun attachView(view: TView) {
        super.attachView(view)

        view.render(viewStateSnapshot)
    }


    override fun subscribeViewState(viewStateObservable: Observable<TViewState>, consumer: ViewStateConsumer<TView, TViewState>) {
        val viewStateStream = if(BuildConfig.DEBUG){
            viewStateObservable
        } else {
            viewStateObservable.map { it as ViewState }
                    .onErrorReturn {
                        FailureViewState()
                    }.filter { it !is FailureViewState }
                    .map { it as TViewState }
        }

        super.subscribeViewState(viewStateStream) { view, viewState ->
            this.viewStateSnapshot = viewState
            consumer.accept(view, viewState)
        }
    }

    private class FailureViewState: ViewState()
}

After changing Unicast to Relay (as ValeriusGC suggest) state is not beeing updated anymore.

from mosby.

sockeqwe avatar sockeqwe commented on August 25, 2024

from mosby.

drbear95 avatar drbear95 commented on August 25, 2024

When can I expect a fix? It is critical for my app because i cannot update to AndroidX

from mosby.

sockeqwe avatar sockeqwe commented on August 25, 2024

from mosby.

michalmatusiak avatar michalmatusiak commented on August 25, 2024

@sockeqwe any news? when it will be fixed?

from mosby.

sockeqwe avatar sockeqwe commented on August 25, 2024

from mosby.

SunMaungOo avatar SunMaungOo commented on August 25, 2024

@sockeqwe any update on the fix? I also got the same problem using AndroidX with version 3.1.1

from mosby.

sockeqwe avatar sockeqwe commented on August 25, 2024

from mosby.

SunMaungOo avatar SunMaungOo commented on August 25, 2024

@sockeqwe Just for your information , the solution provided by ValeriusGC which is changing it to ReplaySubject fix the problem. I don't know what effect it will have on other components but it fix the problem described.

from mosby.

paul-wag avatar paul-wag commented on August 25, 2024

Wish this had a solution.....

from mosby.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.