Christopher Elías
05/31/2021, 8:43 PM@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
fun <T : Any, U : Any> Observable<T>.notOfType(clazz: Class<U>): Observable<T> {
checkNotNull(clazz) { "clazz is null" }
return filter { !clazz.isInstance(it) }
}
/**
* take only the first ever InitialIntent and all intents of other types
* to avoid reloading data on config changes
*/
private val intentFilter: ObservableTransformer<TasksIntent, TasksIntent>
get() = ObservableTransformer { intents ->
intents.publish { shared ->
Observable.merge(
shared.ofType(TasksIntent.InitialIntent::class.java).take(1),
shared.notOfType(TasksIntent.InitialIntent::class.java)
)
}
}
Is for avoid fire the InitialIntent twice (MVI pattern) can someone know how can I accomplish this? My current implementation of it kinda sucks https://github.com/ChristopherME/counter-android-mvi/blob/685756dca1a6f0e89627cb0e[…]myapplication/presentation/features/counter/CounterViewModel.ktjulian
05/31/2021, 9:23 PMChannel
for actions
instead of MutableStateFlow
?Christopher Elías
05/31/2021, 9:27 PM