null && isDataLoading) { populateTask() } } val taskIdIsExist = taskId.filter { it.isNotEmpty() } val isEditTask = Observables.combineLatest( dataLoading, taskIdIsExist ).filter { (isDataLoading, _) -> isDataLoading.not() } .distinctUntilChanged() .map { (_, taskId) -> taskId } .share() private val taskId = PublishSubject.create<String>() private val dataLoading = BehaviorSubject.createDefault(false) fun start(taskId: String?) { this.taskId.onNext(taskId ?: "") }