-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resource computation block #2571
Conversation
}.use { it } | ||
} shouldBe "error".left() | ||
// Should be ExitCase.Cancelled but still Failure due to ShortCircuit | ||
// Cont<R, A> will fix this issue by properly shifting and cancelling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌🏾 one awesome feature
arrow-libs/fx/arrow-fx-coroutines/src/commonMain/kotlin/arrow/fx/coroutines/Resource.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome 🙌🏾
@@ -496,36 +530,6 @@ public sealed class Resource<out A> { | |||
public fun <A> defer(f: suspend () -> Resource<A>): Resource<A> = | |||
Resource.Defer(f) | |||
} | |||
|
|||
private suspend fun continueLoop( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌🏾
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @nomisRev !
This PR adds a Computation block DSL for
Resource
.It also rewrites the internals of
Resource
slightly, it now uses Kotlin Coroutines to unroll Resource through bracketingsuspend
.This way we can guarantee that for every
Resource
that startedacquisition
we will call the finalizer in order (FIFO).