Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tunjid committed Feb 16, 2024
1 parent 75c4b50 commit d0ad35a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ class SnailStateHolder(
private val speed: Flow<Speed> = scope.speedFlow()

private val speedChanges: Flow<Mutation<Snail7State>> = speed
.map { mutation { copy(speed = it) } }
.map { mutationOf { copy(speed = it) } }

private val progressChanges: Flow<Mutation<Snail7State>> = speed
.toInterval()
.map { mutation { copy(progress = (progress + 1) % 100) } }
.map { mutationOf { copy(progress = (progress + 1) % 100) } }

private val stateMutator = scope.stateFlowMutator(
initialState = Snail7State(),
Expand Down Expand Up @@ -166,11 +166,11 @@ A `StateFlow` `Mutator` of the above can be created by:
when (val action = type()) {
is Action.Add -> action.flow
.map {
mutation { copy(count = count + value) }
mutationOf { copy(count = count + value) }
}
is Action.Subtract -> action.flow
.map {
mutation { copy(count = count - value) }
mutationOf { copy(count = count - value) }
}
}
}
Expand Down Expand Up @@ -206,15 +206,15 @@ val mutator = scope.actionStateFlowMutator<Action, State>(
is Action.Fetch -> action.flow
.map { fetch ->
val fetched = repository.get(fetch.query)
mutation {
mutationOf {
copy(
items = (items + fetched).sortedWith(comparator),
)
}
}
is Action.Sort -> action.flow
.mapLatest { sort ->
mutation {
mutationOf {
copy(
comparator = sort.comparator,
items = items.sortedWith(comparator)
Expand Down

0 comments on commit d0ad35a

Please sign in to comment.