From 26a4d98ffcaaaafc76fc6a6bebbee1d4fd116cfe Mon Sep 17 00:00:00 2001 From: Iliyan Germanov Date: Thu, 21 Apr 2022 00:22:06 +0300 Subject: [PATCH] Implement `then` for composing "actions" --- app/src/main/java/com/ivy/wallet/domain/action/Action.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/com/ivy/wallet/domain/action/Action.kt b/app/src/main/java/com/ivy/wallet/domain/action/Action.kt index 2b2b5abc78..4c46662198 100644 --- a/app/src/main/java/com/ivy/wallet/domain/action/Action.kt +++ b/app/src/main/java/com/ivy/wallet/domain/action/Action.kt @@ -27,6 +27,13 @@ infix fun Action.after(act1: Action): Action = objec } } +infix fun Action.then(act2: Action): Action = object : Action() { + override suspend fun A.willDo(): C { + val b = this@then(this) + return act2(b) + } +} + ///** // * Action composition example // */