All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.episode6.redux.ext.kt Maven / Gradle / Ivy

There is a newer version: 1.0.0-alpha02
Show newest version
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