Created
November 4, 2019 11:59
-
-
Save AndSky90/b998efdaf9cbe23decf58022bc135e34 to your computer and use it in GitHub Desktop.
CompositeDisposable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val compositeDisposable = CompositeDisposable() | |
private val photoChangeState: Subject<Boolean> = PublishSubject.create() | |
private var isPhotoChanged: Boolean = false | |
set(value) { | |
field = value | |
photoChangeState.onNext(value) | |
} | |
//--------- | |
compositeDisposable.add(Observable.combineLatest( | |
/**устанавливаем листенеры полей*/ | |
surnameForm.getValidatingObservable(), | |
nameForm.getValidatingObservable(), | |
patronymicForm.getValidatingObservable(), | |
photoChangeState, | |
Function4<Boolean, Boolean, Boolean, Boolean, Boolean> { nameIsPass, surnameIsPass, patronymicIsPass, photoChanged -> | |
/**активируем кнопку, если поля ФИО нормальные и поменялось ФИО или фото*/ | |
nameIsPass && surnameIsPass && patronymicIsPass && | |
(surnameForm.text != data.user!!.surname.orEmpty() | |
|| nameForm.text != data.user!!.name.orEmpty() | |
|| patronymicForm.text != data.user!!.patronymic.orEmpty() | |
|| photoChanged) | |
}).subscribe { setSaveButtonState(it) }) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment