commonMain.com.episode6.redux.ext.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core Show documentation
Show all versions of core Show documentation
Core implementation of Redux StoreFlow
package com.episode6.redux
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.map
fun StoreFlow.mapStore(mapper: (T) -> R): StoreFlow {
val newFlow = map { mapper(it) }.distinctUntilChanged()
return object : StoreFlow, Flow by newFlow {
override val initialState: R get() = mapper([email protected])
override val state: R get() = mapper([email protected])
override fun dispatch(action: Action) = [email protected](action)
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy