-
Notifications
You must be signed in to change notification settings - Fork 448
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
Add AutoClose module #3356
Add AutoClose module #3356
Conversation
…to sv-arrow-autocloseable
From the release post, if this change is too disruptive we can also just put everything directly into 2.x. cc\ @serras |
Kover Report
|
@nomisRev Do we need to maintain source compatibility with the pre-existing impl? Or are we free to break some signatures? |
I’m a bit worried about having both This is very similar to what I faced in About splitting |
I've thought about it a bit more (bus rides give a lot of time for thinking), and I think we can easily explain why you need both concepts. I've noticed that I would go for including this in 1.2.2, and update the documentation about Resource management to talk about both at the same time. |
This IMO is quite simple, but I guess there is an essential piece of documentation missing.
Similar to how non-suspend function can be called from suspend function, can Not sure if that clears it up, but I find this a reasonable and necessary split. In pure land, we would always use
It's not completely explained in my original PR comment, but my idea is not to split but rather separate I have a personal use-case just for |
@serras saw your message too late 😅 We definitely need to include it into the docs, I will raise a PR tomorrow or the day after 👍
I was planning to take a look at 2.0 first, to see what the options are. So if you have any ideas, please just jump to 2.0 and feel free to make some breaking changes there if it results in a nicer API 😉 |
I would prefer that, as much as possible, |
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.
Not very familiar with the resource
dsl so I couldn't help much there.
arrow-libs/core/arrow-autocloseable/src/commonMain/kotlin/arrow/AutoCloseScope.kt
Outdated
Show resolved
Hide resolved
arrow-libs/core/arrow-autocloseable/src/commonMain/kotlin/arrow/AutoCloseScope.kt
Outdated
Show resolved
Hide resolved
arrow-libs/core/arrow-autocloseable/src/commonMain/kotlin/arrow/AutoCloseScope.kt
Outdated
Show resolved
Hide resolved
arrow-libs/core/arrow-autocloseable/src/commonTest/kotlin/arrow/AutoCloseTest.kt
Outdated
Show resolved
Hide resolved
arrow-libs/core/arrow-autocloseable/src/commonTest/kotlin/arrow/AutoCloseTest.kt
Outdated
Show resolved
Hide resolved
arrow-libs/core/arrow-autocloseable/src/commonTest/kotlin/arrow/AutoCloseTest.kt
Outdated
Show resolved
Hide resolved
arrow-libs/core/arrow-autocloseable/src/jvmMain/kotlin/arrow/AutoCloseableExtensions.kt
Outdated
Show resolved
Hide resolved
…to sv-arrow-autocloseable
Adds a new module with same support as Resource, but without requiring KotlinX or suspension.
I plan on splitting
Resource
from Arrow Fx, but we either do it here or we do it in 2.0 branch since there are some breaking changes in the Resource API. WDYT? I'm open for all ideas 😅Some goals are to be able to use this in other libraries, and projects without having to introduce Arrow as a base dependency.
For example
SuspendApp
could include justAutoCloseable
andResource
support but it doesn't need anything else by doing this we can provide a much more elegantSuspendApp
API, whilst keeping everything working together nicely, etc. I've had the use for this pattern quite a lot since I started adopting this DSL approach for resources.