Mutator
A tiny, multiplatform, redux-like library that makes it easy to transform streams of actions into streams of state

TJ Dahunsi
Feb 24 2022 ยท 1 min
A Mutator is an abstract data type declaration of the form:
interface Mutator<Action : Any, State : Any> { val state: State val accept: (Action) -> Unit }
where Action defines an input type that yields production of the State output type. In other words, a Mutator represents a production pipeline of State which may be altered by input of Action.
The unit of change for processing an Action into a new State is a Mutation, a data class hosting a lambda with the existing State as a receiver, that when invoked produces a new State.
data class Mutation<T : Any>( val mutate: T.() -> T )
The default implementation is the stateFlowMutator.
A sample app utilizing it (and coincidentally what this post was written with) can be found here:
.