diff --git a/core/src/commonMain/kotlin/com/tunjid/mutator/ActionStateProducer.kt b/core/src/commonMain/kotlin/com/tunjid/mutator/Mutator.kt similarity index 88% rename from core/src/commonMain/kotlin/com/tunjid/mutator/ActionStateProducer.kt rename to core/src/commonMain/kotlin/com/tunjid/mutator/Mutator.kt index fd44c2a..534b7ec 100644 --- a/core/src/commonMain/kotlin/com/tunjid/mutator/ActionStateProducer.kt +++ b/core/src/commonMain/kotlin/com/tunjid/mutator/Mutator.kt @@ -38,17 +38,17 @@ interface ActionStateProducer : StateProducer /** * Syntactic sugar for creating a [Mutation] */ -inline fun mutation(noinline mutation: State.() -> State): Mutation = mutation +inline fun mutationOf(noinline mutation: State.() -> State): Mutation = mutation /** * Identity [Mutation] function; semantically a no op [Mutation] */ -fun identity(): Mutation = mutation { this } +fun identity(): Mutation = mutationOf { this } /** * Combines two [Mutation] instances into a single [Mutation] */ -operator fun Mutation.plus(other: Mutation) = mutation inner@{ +operator fun Mutation.plus(other: Mutation) = mutationOf inner@{ val result = this@plus(this@inner) other.invoke(result) } diff --git a/coroutines/src/commonMain/kotlin/com/tunjid/mutator/coroutines/ActionStateFlowProducer.kt b/coroutines/src/commonMain/kotlin/com/tunjid/mutator/coroutines/ActionStateFlowProducer.kt index 9e9f633..b4ffe20 100644 --- a/coroutines/src/commonMain/kotlin/com/tunjid/mutator/coroutines/ActionStateFlowProducer.kt +++ b/coroutines/src/commonMain/kotlin/com/tunjid/mutator/coroutines/ActionStateFlowProducer.kt @@ -51,14 +51,14 @@ typealias SuspendingStateHolder = StateHolder State> fun CoroutineScope.actionStateFlowProducer( initialState: State, started: SharingStarted = SharingStarted.WhileSubscribed(DEFAULT_STOP_TIMEOUT_MILLIS), - mutationFlows: List>> = listOf(), + inputs: List>> = listOf(), stateTransform: (Flow) -> Flow = { it }, actionTransform: SuspendingStateHolder.(Flow) -> Flow> = { emptyFlow() } ): ActionStateProducer> = ActionStateFlowProducer( coroutineScope = this, initialState = initialState, started = started, - mutationFlows = mutationFlows, + inputs = inputs, stateTransform = stateTransform, actionTransform = actionTransform ) @@ -67,7 +67,7 @@ private class ActionStateFlowProducer( coroutineScope: CoroutineScope, initialState: State, started: SharingStarted, - mutationFlows: List>>, + inputs: List>>, stateTransform: (Flow) -> Flow = { it }, actionTransform: SuspendingStateHolder.(Flow) -> Flow> ) : ActionStateProducer>, @@ -86,7 +86,7 @@ private class ActionStateFlowProducer( initialState = initialState, started = started, stateTransform = stateTransform, - mutationFlows = mutationFlows + actionTransform(stateReader, actions.receiveAsFlow()) + inputs = inputs + actionTransform(stateReader, actions.receiveAsFlow()) ) override val accept: (Action) -> Unit = { action -> diff --git a/coroutines/src/commonMain/kotlin/com/tunjid/mutator/coroutines/FlowMutationExt.kt b/coroutines/src/commonMain/kotlin/com/tunjid/mutator/coroutines/FlowMutationExt.kt index 5b6b1d5..bd59cf0 100644 --- a/coroutines/src/commonMain/kotlin/com/tunjid/mutator/coroutines/FlowMutationExt.kt +++ b/coroutines/src/commonMain/kotlin/com/tunjid/mutator/coroutines/FlowMutationExt.kt @@ -17,7 +17,7 @@ package com.tunjid.mutator.coroutines import com.tunjid.mutator.Mutation -import com.tunjid.mutator.mutation +import com.tunjid.mutator.mutationOf import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.FlowCollector import kotlinx.coroutines.flow.flatMapConcat @@ -33,7 +33,7 @@ import kotlinx.coroutines.flow.mapLatest inline fun Flow.mapToMutation( crossinline mapper: State.(T) -> State ): Flow> = - map { mutation { mapper(it) } } + map { mutationOf { mapper(it) } } /** * Maps the latest emission of [T] into a single mutation of [State] @@ -42,7 +42,7 @@ inline fun Flow.mapToMutation( inline fun Flow.mapLatestToMutation( crossinline mapper: State.(T) -> State ): Flow> = - mapLatest { mutation { mapper(it) } } + mapLatest { mutationOf { mapper(it) } } /** * Maps each emission of [T] into multiple mutations of [State] diff --git a/coroutines/src/commonMain/kotlin/com/tunjid/mutator/coroutines/StateFlowProducer.kt b/coroutines/src/commonMain/kotlin/com/tunjid/mutator/coroutines/StateFlowProducer.kt index 0c13955..6d24f14 100644 --- a/coroutines/src/commonMain/kotlin/com/tunjid/mutator/coroutines/StateFlowProducer.kt +++ b/coroutines/src/commonMain/kotlin/com/tunjid/mutator/coroutines/StateFlowProducer.kt @@ -33,12 +33,12 @@ import kotlinx.coroutines.launch fun CoroutineScope.stateFlowProducer( initialState: State, started: SharingStarted = SharingStarted.WhileSubscribed(), - mutationFlows: List>> + inputs: List>> ) = StateFlowProducer( scope = this, initialState = initialState, started = started, - mutationFlows = mutationFlows + inputs = inputs ) /** @@ -48,14 +48,14 @@ class StateFlowProducer internal constructor( private val scope: CoroutineScope, initialState: State, started: SharingStarted = SharingStarted.WhileSubscribed(), - mutationFlows: List>> + inputs: List>> ) : StateProducer> { private val parallelExecutedTasks = MutableSharedFlow>>() override val state = scope.produceState( initialState = initialState, started = started, - mutationFlows = mutationFlows + parallelExecutedTasks.flatMapMerge( + inputs = inputs + parallelExecutedTasks.flatMapMerge( concurrency = Int.MAX_VALUE, transform = { it } ) diff --git a/coroutines/src/commonMain/kotlin/com/tunjid/mutator/coroutines/StateProduction.kt b/coroutines/src/commonMain/kotlin/com/tunjid/mutator/coroutines/StateProduction.kt index 2ac3f61..e5af0d2 100644 --- a/coroutines/src/commonMain/kotlin/com/tunjid/mutator/coroutines/StateProduction.kt +++ b/coroutines/src/commonMain/kotlin/com/tunjid/mutator/coroutines/StateProduction.kt @@ -31,14 +31,14 @@ import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch /** - * Produces a [StateFlow] by merging [mutationFlows] and reducing them into an + * Produces a [StateFlow] by merging [inputs] and reducing them into an * [initialState] state within [this] [CoroutineScope] */ fun CoroutineScope.produceState( initialState: State, started: SharingStarted, stateTransform: (Flow) -> Flow = { it }, - mutationFlows: List>> + inputs: List>> ): StateFlow { // Set the seed for the state var seed = initialState @@ -47,7 +47,7 @@ fun CoroutineScope.produceState( return stateTransform( flow { emitAll( - merge(*mutationFlows.toTypedArray()) + merge(*inputs.toTypedArray()) // Reduce into the seed so if resubscribed, the last value of state is persisted // when the flow pipeline is started again .reduceInto(seed) diff --git a/coroutines/src/commonTest/kotlin/com/tunjid/mutator/coroutines/FlowMutationStreamKtTest.kt b/coroutines/src/commonTest/kotlin/com/tunjid/mutator/coroutines/FlowMutationStreamKtTest.kt index 23bb090..331901a 100644 --- a/coroutines/src/commonTest/kotlin/com/tunjid/mutator/coroutines/FlowMutationStreamKtTest.kt +++ b/coroutines/src/commonTest/kotlin/com/tunjid/mutator/coroutines/FlowMutationStreamKtTest.kt @@ -16,7 +16,7 @@ package com.tunjid.mutator.coroutines -import com.tunjid.mutator.mutation +import com.tunjid.mutator.mutationOf import kotlinx.coroutines.channels.BufferOverflow import kotlinx.coroutines.delay import kotlinx.coroutines.flow.asFlow @@ -210,14 +210,14 @@ class FlowMutationStreamKtTest { when (val type = type()) { is Split.Action.Regular -> type.flow .map { - mutation { copy(regularCount = regularCount + 1) } + mutationOf { copy(regularCount = regularCount + 1) } } is Split.Action.Delayed -> type.flow .map { // Delay when processing this action delay(1000) - mutation { copy(delayedCount = delayedCount + 1) } + mutationOf { copy(delayedCount = delayedCount + 1) } } } } diff --git a/coroutines/src/commonTest/kotlin/com/tunjid/mutator/coroutines/State.kt b/coroutines/src/commonTest/kotlin/com/tunjid/mutator/coroutines/State.kt index 50d99b4..28d4d52 100644 --- a/coroutines/src/commonTest/kotlin/com/tunjid/mutator/coroutines/State.kt +++ b/coroutines/src/commonTest/kotlin/com/tunjid/mutator/coroutines/State.kt @@ -17,7 +17,7 @@ package com.tunjid.mutator.coroutines import com.tunjid.mutator.Mutation -import com.tunjid.mutator.mutation +import com.tunjid.mutator.mutationOf data class State( val count: Double = 0.0 @@ -41,8 +41,8 @@ sealed class DoubleAction : Action() { val Action.mutation: Mutation get() = when (this) { - is IntAction.Add -> mutation { copy(count = count + value) } - is IntAction.Subtract -> mutation { copy(count = count - value) } - is DoubleAction.Divide -> mutation { copy(count = count / value) } - is DoubleAction.Multiply -> mutation { copy(count = count * value) } + is IntAction.Add -> mutationOf { copy(count = count + value) } + is IntAction.Subtract -> mutationOf { copy(count = count - value) } + is DoubleAction.Divide -> mutationOf { copy(count = count / value) } + is DoubleAction.Multiply -> mutationOf { copy(count = count * value) } } diff --git a/coroutines/src/commonTest/kotlin/com/tunjid/mutator/coroutines/StateProductionKtTest.kt b/coroutines/src/commonTest/kotlin/com/tunjid/mutator/coroutines/StateProductionKtTest.kt index ce6bfb5..4850cd8 100644 --- a/coroutines/src/commonTest/kotlin/com/tunjid/mutator/coroutines/StateProductionKtTest.kt +++ b/coroutines/src/commonTest/kotlin/com/tunjid/mutator/coroutines/StateProductionKtTest.kt @@ -18,7 +18,7 @@ package com.tunjid.mutator.coroutines import app.cash.turbine.test import com.tunjid.mutator.Mutation -import com.tunjid.mutator.mutation +import com.tunjid.mutator.mutationOf import com.tunjid.mutator.plus import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -60,7 +60,7 @@ class StateProductionKtTest { val state = scope.produceState( initialState = State(), started = SharingStarted.WhileSubscribed(), - mutationFlows = listOf( + inputs = listOf( eventMutations ) ) @@ -79,7 +79,7 @@ class StateProductionKtTest { val state = scope.produceState( initialState = State(), started = SharingStarted.WhileSubscribed(), - mutationFlows = listOf( + inputs = listOf( eventMutations ) ) @@ -105,14 +105,14 @@ class StateProductionKtTest { val state = scope.produceState( initialState = State(), started = SharingStarted.WhileSubscribed(), - mutationFlows = listOf( + inputs = listOf( eventMutations, flow { delay(1000) - emit(mutation { copy(count = 3.0) }) + emit(mutationOf { copy(count = 3.0) }) delay(1000) - emit(mutation { copy(count = 7.0) }) + emit(mutationOf { copy(count = 7.0) }) } ) ) @@ -135,13 +135,13 @@ class StateProductionKtTest { @Test fun test_state_change_addition() { - val additionMutation = mutation { + val additionMutation = mutationOf { copy(count = count + 1) } + - mutation { + mutationOf { copy(count = count + 1) } + - mutation { + mutationOf { copy(count = count + 1) } diff --git a/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail10.kt b/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail10.kt index c2c093c..5734861 100644 --- a/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail10.kt +++ b/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail10.kt @@ -36,7 +36,7 @@ import com.tunjid.mutator.demo.udfvisualizer.Event import com.tunjid.mutator.demo.udfvisualizer.Marble import com.tunjid.mutator.demo.udfvisualizer.UDFVisualizer import com.tunjid.mutator.demo.udfvisualizer.udfVisualizerStateHolder -import com.tunjid.mutator.mutation +import com.tunjid.mutator.mutationOf import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.currentCoroutineContext @@ -70,16 +70,16 @@ class Snail10StateHolder( private val speed: Flow = scope.speedFlow() private val speedChanges: Flow> = speed - .map { mutation { copy(speed = it) } } + .map { mutationOf { copy(speed = it) } } private val progressChanges: Flow> = speed .toInterval() - .map { mutation { copy(progress = (progress + 1) % 100) } } + .map { mutationOf { copy(progress = (progress + 1) % 100) } } private val stateProducer = scope.stateFlowProducer( initialState = Snail10State(), started = SharingStarted.WhileSubscribed(), - mutationFlows = listOf( + inputs = listOf( speedChanges, progressChanges, ) diff --git a/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail11.kt b/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail11.kt index 787e423..94efe1e 100644 --- a/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail11.kt +++ b/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail11.kt @@ -37,7 +37,7 @@ import com.tunjid.mutator.demo.udfvisualizer.Marble import com.tunjid.mutator.demo.udfvisualizer.Event import com.tunjid.mutator.demo.udfvisualizer.UDFVisualizer import com.tunjid.mutator.demo.udfvisualizer.udfVisualizerStateHolder -import com.tunjid.mutator.mutation +import com.tunjid.mutator.mutationOf import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.SharingStarted @@ -86,17 +86,17 @@ class Snail11StateHolder( private val speed: Flow = scope.speedFlow() private val speedChanges: Flow> = speed - .map { mutation { copy(speed = it) } } + .map { mutationOf { copy(speed = it) } } private val progressChanges: Flow> = speed .toInterval() - .map { mutation { copy(progress = (progress + 1) % 100) } } + .map { mutationOf { copy(progress = (progress + 1) % 100) } } private val mutator = scope.actionStateFlowProducer( initialState = Snail11State(), started = SharingStarted.WhileSubscribed(), - mutationFlows = listOf( + inputs = listOf( speedChanges, progressChanges ), @@ -117,25 +117,25 @@ class Snail11StateHolder( private fun Flow.colorMutations(): Flow> = mapLatest { - mutation { copy(colorIndex = it.index) } + mutationOf { copy(colorIndex = it.index) } } private fun Flow.progressMutations(): Flow> = mapLatest { - mutation { copy(progress = it.progress) } + mutationOf { copy(progress = it.progress) } } private fun Flow.modeMutations(): Flow> = flatMapLatest { (isDark, startColors) -> flow { - emit(mutation { copy(isDark = isDark) }) + emit(mutationOf { copy(isDark = isDark) }) emitAll( interpolateColors( startColors = startColors.map(Color::argb).toIntArray(), endColors = MutedColors.colors(isDark).map(Color::argb).toIntArray() ) .map { (progress, colors) -> - mutation { + mutationOf { copy( colorInterpolationProgress = progress, colors = colors diff --git a/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail5.kt b/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail5.kt index 3a0b009..bb76f77 100644 --- a/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail5.kt +++ b/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail5.kt @@ -35,7 +35,7 @@ import com.tunjid.mutator.demo.udfvisualizer.Marble import com.tunjid.mutator.demo.udfvisualizer.Event import com.tunjid.mutator.demo.udfvisualizer.UDFVisualizer import com.tunjid.mutator.demo.udfvisualizer.udfVisualizerStateHolder -import com.tunjid.mutator.mutation +import com.tunjid.mutator.mutationOf import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow @@ -62,11 +62,11 @@ class Snail5StateHolder( private val speed: Flow = scope.speedFlow() private val speedChanges: Flow> = speed - .map { mutation { copy(speed = it) } } + .map { mutationOf { copy(speed = it) } } private val progressChanges: Flow> = speed .toInterval() - .map { mutation { copy(progress = (progress + 1) % 100) } } + .map { mutationOf { copy(progress = (progress + 1) % 100) } } private val changeEvents = MutableSharedFlow>() diff --git a/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail6.kt b/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail6.kt index 024c40f..2bc1304 100644 --- a/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail6.kt +++ b/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail6.kt @@ -35,7 +35,7 @@ import com.tunjid.mutator.demo.udfvisualizer.Marble import com.tunjid.mutator.demo.udfvisualizer.Event import com.tunjid.mutator.demo.udfvisualizer.UDFVisualizer import com.tunjid.mutator.demo.udfvisualizer.udfVisualizerStateHolder -import com.tunjid.mutator.mutation +import com.tunjid.mutator.mutationOf import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow @@ -61,11 +61,11 @@ class Snail6StateHolder( private val speed: Flow = scope.speedFlow() private val speedChanges: Flow> = speed - .map { mutation { copy(speed = it) } } + .map { mutationOf { copy(speed = it) } } private val progressChanges: Flow> = speed .toInterval() - .map { mutation { copy(progress = (progress + 1) % 100) } } + .map { mutationOf { copy(progress = (progress + 1) % 100) } } private val changeEvents = MutableSharedFlow>() diff --git a/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail7.kt b/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail7.kt index 1d97a09..f56e114 100644 --- a/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail7.kt +++ b/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail7.kt @@ -36,7 +36,7 @@ import com.tunjid.mutator.demo.udfvisualizer.Event import com.tunjid.mutator.demo.udfvisualizer.Marble import com.tunjid.mutator.demo.udfvisualizer.UDFVisualizer import com.tunjid.mutator.demo.udfvisualizer.udfVisualizerStateHolder -import com.tunjid.mutator.mutation +import com.tunjid.mutator.mutationOf import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.SharingStarted @@ -57,16 +57,16 @@ class Snail7StateHolder( private val speed: Flow = scope.speedFlow() private val speedChanges: Flow> = speed - .map { mutation { copy(speed = it) } } + .map { mutationOf { copy(speed = it) } } private val progressChanges: Flow> = speed .toInterval() - .map { mutation { copy(progress = (progress + 1) % 100) } } + .map { mutationOf { copy(progress = (progress + 1) % 100) } } private val stateProducer = scope.stateFlowProducer( initialState = Snail7State(), started = SharingStarted.WhileSubscribed(), - mutationFlows = listOf( + inputs = listOf( speedChanges, progressChanges, ) diff --git a/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail8.kt b/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail8.kt index 5d36e13..26d8e9f 100644 --- a/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail8.kt +++ b/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail8.kt @@ -36,7 +36,7 @@ import com.tunjid.mutator.demo.udfvisualizer.Event import com.tunjid.mutator.demo.udfvisualizer.Marble import com.tunjid.mutator.demo.udfvisualizer.UDFVisualizer import com.tunjid.mutator.demo.udfvisualizer.udfVisualizerStateHolder -import com.tunjid.mutator.mutation +import com.tunjid.mutator.mutationOf import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.SharingStarted @@ -66,16 +66,16 @@ class Snail8StateHolder( private val speed: Flow = scope.speedFlow() private val speedChanges: Flow> = speed - .map { mutation { copy(speed = it) } } + .map { mutationOf { copy(speed = it) } } private val progressChanges: Flow> = speed .toInterval() - .map { mutation { copy(progress = (progress + 1) % 100) } } + .map { mutationOf { copy(progress = (progress + 1) % 100) } } private val stateProducer = scope.stateFlowProducer( initialState = Snail8State(), started = SharingStarted.WhileSubscribed(), - mutationFlows = listOf( + inputs = listOf( speedChanges, progressChanges, ) diff --git a/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail9.kt b/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail9.kt index 1855271..888942c 100644 --- a/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail9.kt +++ b/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/snails/Snail9.kt @@ -36,7 +36,7 @@ import com.tunjid.mutator.demo.udfvisualizer.Event import com.tunjid.mutator.demo.udfvisualizer.Marble import com.tunjid.mutator.demo.udfvisualizer.UDFVisualizer import com.tunjid.mutator.demo.udfvisualizer.udfVisualizerStateHolder -import com.tunjid.mutator.mutation +import com.tunjid.mutator.mutationOf import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.SharingStarted @@ -67,16 +67,16 @@ class Snail9StateHolder( private val speed: Flow = scope.speedFlow() private val speedChanges: Flow> = speed - .map { mutation { copy(speed = it) } } + .map { mutationOf { copy(speed = it) } } private val progressChanges: Flow> = speed .toInterval() - .map { mutation { copy(progress = (progress + 1) % 100) } } + .map { mutationOf { copy(progress = (progress + 1) % 100) } } private val stateProducer = scope.stateFlowProducer( initialState = Snail9State(), started = SharingStarted.WhileSubscribed(), - mutationFlows = listOf( + inputs = listOf( speedChanges, progressChanges, ) diff --git a/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/udfvisualizer/UDFVisualizerStateHolder.kt b/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/udfvisualizer/UDFVisualizerStateHolder.kt index 8d62737..d147352 100644 --- a/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/udfvisualizer/UDFVisualizerStateHolder.kt +++ b/demo/src/commonMain/kotlin/com/tunjid/mutator/demo/udfvisualizer/UDFVisualizerStateHolder.kt @@ -22,7 +22,7 @@ import com.tunjid.mutator.ActionStateProducer import com.tunjid.mutator.coroutines.actionStateFlowProducer import com.tunjid.mutator.demo.Color import com.tunjid.mutator.demo.intervalFlow -import com.tunjid.mutator.mutation +import com.tunjid.mutator.mutationOf import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.StateFlow @@ -77,15 +77,15 @@ fun udfVisualizerStateHolder( scope: CoroutineScope ): ActionStateProducer> = scope.actionStateFlowProducer( initialState = State(), - mutationFlows = listOf(frames()), + inputs = listOf(frames()), actionTransform = { it.stateMutations() }, ) private fun frames(): Flow> = intervalFlow(10) - .map { mutation { advanceFrame() } } + .map { mutationOf { advanceFrame() } } private fun Flow.stateMutations(): Flow> = - map { mutation { this + it } } + map { mutationOf { this + it } } /** * Reduces the [action] into the [State] diff --git a/readme.md b/readme.md index 6e0b0c2..1a0f691 100644 --- a/readme.md +++ b/readme.md @@ -43,7 +43,7 @@ At the moment, there are two implementations: fun CoroutineScope.stateFlowProducer( initialState: State, started: SharingStarted, - mutationFlows: List>> + inputs: List>> ): StateProducer> ``` @@ -53,7 +53,7 @@ and fun CoroutineScope.actionStateFlowProducer( initialState: State, started: SharingStarted, - mutationFlows: List>>, + inputs: List>>, actionTransform: (Flow) -> Flow> ): StateProducer> ```