This repository has been archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 721
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8eb42e0
commit 34605f9
Showing
7 changed files
with
116 additions
and
74 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
app/src/main/java/com/ivy/wallet/domain/action/budget/BudgetsAct.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.ivy.wallet.domain.action.budget | ||
|
||
import com.ivy.fp.action.FPAction | ||
import com.ivy.fp.action.thenMap | ||
import com.ivy.wallet.domain.data.core.Budget | ||
import com.ivy.wallet.io.persistence.dao.BudgetDao | ||
import javax.inject.Inject | ||
|
||
class BudgetsAct @Inject constructor( | ||
private val budgetDao: BudgetDao | ||
) : FPAction<Unit, List<Budget>>() { | ||
override suspend fun Unit.compose(): suspend () -> List<Budget> = suspend { | ||
budgetDao.findAll() | ||
} thenMap { it.toDomain() } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.ivy.fp | ||
|
||
suspend fun <A> List<A>.sumOfSuspend( | ||
selector: suspend (A) -> Double | ||
): Double { | ||
var sum = 0.0 | ||
for (item in this) { | ||
sum += selector(item) | ||
} | ||
return sum | ||
} |