artem-zinnatullin / RxUi

Implementation of pure functional concept of talking to Android View layer in a Reactive way
https://artemzin.com/blog/rxui-talking-to-android-view-layer-in-a-reactive-way/
MIT License
261 stars 22 forks source link

After rotation "Sign In" button is being disabled #27

Open kokeroulis opened 8 years ago

kokeroulis commented 8 years ago

Steps to reproduce

  1. Add a login name and a password
  2. Rotate the screen
  3. Sign In button is no longer clickable
marukami commented 8 years ago

It looks like the example is not associative. If you swap the order of the follow around; then it works

subscription += credentials
                .filter { it.third }
                .map { Unit }
                .bind(view.signInEnable)
subscription += credentials
                .filter { !it.third }
                .map { Unit }
                .startWith(Unit)
                .bind(view.signInDisable)

Is there any reason why you would not map credentials to view.signInEnable and just replace

val signInEnable: Func1<Observable<Unit>, Subscription>
val signInDisable: Func1<Observable<Unit>, Subscription>

with

val signInEnable: Func1<Observable<Boolean>, Subscription> 

?

kokeroulis commented 8 years ago

I think that there is a race condition here. After you fill in the login and the password and you rotate the screen you get back the following

          presenter  E  signInDisable true
                     E  signInDisable true
                     E  signInEnable true
               View  E  signInEnable
                     E  singInDisable
                     E  singInDisable

shouldn't the "view" consume the signals the other way around?

https://gist.github.com/kokeroulis/d4dff13f7e4f814c8a05d7356fc655f6