Skip to content

Instantly share code, notes, and snippets.

@zsoltk
Last active September 11, 2022 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zsoltk/25d0d505f11cf0ce89b2cfcfaa83dbb2 to your computer and use it in GitHub Desktop.
Save zsoltk/25d0d505f11cf0ce89b2cfcfaa83dbb2 to your computer and use it in GitHub Desktop.
internal class PromoteAll<T : Any> : CardsOperation<T> {
override fun invoke(elements: CardsElements<T>): CardsElements<T> =
elements.map {
it.transitionTo(
// This uses State.next() we defined earlier:
newTargetState = it.targetState.next(),
operation = this
)
}
}
internal fun <T : Any> Cards<T>.promoteAll() {
accept(PromoteAll())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment