-
Notifications
You must be signed in to change notification settings - Fork 3
Higher order sagas #165
Comments
Hey @pinguinjkeke, Thanks for the feedback! That pattern seems dangerous :/ In your snippet both the saga {
saga({
withContext(Dispatchers.IO) {
retry(5) { doSomething() }
}
}) {
// same levels of nesting on rollback
}
} It doesn't entirely resolve you problem, but it already makes the indentation a bit smaller. I see you also have indentation configured to 4-spaces, which I am personally not a fan of especially in Kotlin which can be quite heavy on DSLs. Albeit that with callback-hell you can never "escape" the callback, but in this case at some point you'll get the result on the lefthand side like regular imperative code. So this can typically be "solved" in Kotlin by applying some best-practices when working with For example: saga {
val result = doSomething()
}
suspend fun SagaEffect.doSomething(): A = saga({
withContext(Dispatchers.IO) {
retry(5) { doSomething() }
}
}) { // same levels of nesting on rollback } To come back to your original question of "higher order", it will introduce a lot of specialised code in every type similar to Not sure if my reply helps you in any way, but I think this is out of the scope of this library. Feel free to reply, or ask any questions you might have. |
Thanks for the detailed answer. |
Thanks for a cool library, but we often get indentation hell
It will be good to have an ability to somehow wrap
saga
for:What do you think?
The text was updated successfully, but these errors were encountered: