@MainThread
    protected void subscribeViewState(@NonNull Observable<VS> viewStateObservable,
                                      @NonNull ViewStateConsumer<V, VS> consumer) {
        if (subscribeViewStateMethodCalled) {
            throw new IllegalStateException(
                    "subscribeViewState() method is only allowed to be called once");
        }
        subscribeViewStateMethodCalled = true;

        if (viewStateObservable == null) {
            throw new NullPointerException("ViewState Observable is null");
        }

        if (consumer == null) {
            throw new NullPointerException("ViewStateBinder is null");
        }

        this.viewStateConsumer = consumer;

        viewStateDisposable = viewStateObservable.subscribeWith(
                new DisposableViewStateObserver<>(viewStateBehaviorSubject));
    }
@ MainThread protected void subscribeViewState ( @ NonNull Observable < VS > viewStateObservable , @ NonNull ViewStateConsumer < V , VS > consumer ) { if ( subscribeViewStateMethodCalled ) { throw new IllegalStateException ( "subscribeViewState() method is only allowed to be called once" ) ; } subscribeViewStateMethodCalled = true ; if ( viewStateObservable == null ) { throw new NullPointerException ( "ViewState Observable is null" ) ; } if ( consumer == null ) { throw new NullPointerException ( "ViewStateBinder is null" ) ; } this . viewStateConsumer = consumer ; viewStateDisposable = viewStateObservable . subscribeWith ( new DisposableViewStateObserver < > ( viewStateBehaviorSubject ) ) ; }
This method subscribes the Observable emitting {@code ViewState} over time to the passed
consumer.
<b>Only invoke this method once! Typically, in {@link #bindIntents()}</b>
<p>
Internally, Mosby will hold some relays to ensure that no items emitted from the ViewState
Observable will be lost while viewState is not attached nor that the subscriptions to
viewState intents will cause memory leaks while viewState detached.
</p>
<p>
Typically, this method is used in {@link #bindIntents()}  like this:
<pre><code>
Observable<MyViewState> viewState =  ... ;
subscribeViewStateConsumerActually(viewState, new ViewStateConsumer() {
@Override
public void accept(MyView view, MyViewState viewState){
view.render(viewState);
}
}
</code></pre>

@param viewStateObservable The Observable emitting new ViewState. Typically, an intent {@link
#intent(ViewIntentBinder)} causes the underlying business logic to do a change and eventually
create a new ViewState.
@param consumer            {@link ViewStateConsumer} The consumer that will update ("render") the view.