Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Implement then for composing "actions"
Browse files Browse the repository at this point in the history
  • Loading branch information
ILIYANGERMANOV committed Apr 20, 2022
1 parent a7defb4 commit 26a4d98
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/src/main/java/com/ivy/wallet/domain/action/Action.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ infix fun <A, B, C> Action<B, C>.after(act1: Action<A, B>): Action<A, C> = objec
}
}

infix fun <A, B, C> Action<A, B>.then(act2: Action<B, C>): Action<A, C> = object : Action<A, C>() {
override suspend fun A.willDo(): C {
val b = this@then(this)
return act2(b)
}
}

///**
// * Action composition example
// */
Expand Down

0 comments on commit 26a4d98

Please sign in to comment.