Skip to content

Instantly share code, notes, and snippets.

Created Sep 27, 2020
What would you like to do?
class ChainAction(
private val action: Action,
private val canExecute: (Response) -> Boolean
) : Action {
private var nextAction: Action? = null
override val name: String =
override fun execute(response: Response) {
if (canExecute(response)) {
fun or(action: ChainAction): ChainAction {
nextAction = action
return this
fun Action.asChain(canExecute: (Response) -> Boolean): ChainAction =
ChainAction(this, canExecute)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment