phldavies
09/16/2022, 11:32 AMResource<A>.allocated()
extension returns Pair<suspend () -> A, suspend(A, ExitCase) -> Unit>
rather than Pair<A, suspend (ExitCase) -> Unit>
. Much like in cats.effect.Resource
I would expect allocated
to actually allocate/acquire the resource (and provide the release).simon.vergauwen
09/16/2022, 11:58 AMsuspend fun allocated(): Pair<supend () -> A, ...
doesn't actually make sense to have suspend
there twice.simon.vergauwen
09/16/2022, 11:59 AMphldavies
09/16/2022, 12:00 PMfun ExitCase(Throwable)
in the companion a little confusing - fun forThrowable
or operator fun invoke
would make more sense imo.simon.vergauwen
09/16/2022, 12:01 PMoperator fun invoke
vs fun ExitCase
?
operator fun invoke
has horrible IDEA support, and many people including myself are moving away from that pattern.simon.vergauwen
09/16/2022, 12:01 PMRandom.kt
and Duration.kt
.simon.vergauwen
09/16/2022, 12:02 PMsimon.vergauwen
09/16/2022, 12:02 PMphldavies
09/16/2022, 12:03 PMimport arrow.fx.coroutines.ExitCase.Companion.ExitCase
a little weird - might be I’m too used to the invoke approach though 😉simon.vergauwen
09/16/2022, 12:04 PMinvoke
import or syntax when typing, and apparently in Android Studio it's much worse. Whilst this doesn't suffer from it. Originally I also found it strange but I got used to it from import kotlin.time.Duration.Companion.milliseconds
simon.vergauwen
09/16/2022, 12:06 PMsuspend
in that signature for the next versions. I already started rolling out the 1.1.3
release so it's a day late 😅
Luckily we're now in a fast path of faster iterations, and preparing the APIs for 2.0.0 next year 🥳 So all, and any feedback is always much appreciated!phldavies
09/16/2022, 12:13 PMsuspend fun <A> Resource<A>.allocate(): Pair<A, suspend (ExitCase) -> Unit> =
allocated().let { (acquire, release) ->
val acquired = acquire()
acquired to { release(acquired, it) }
}
simon.vergauwen
10/05/2022, 3:41 PMDelicate
and only released in last patch version.phldavies
10/05/2022, 3:45 PMsimon.vergauwen
10/05/2022, 3:46 PMDeprecationLevel.HIDDEN
and then we can do a small API breaking change (Kotlin) only.simon.vergauwen
10/06/2022, 9:16 AMphldavies
10/06/2022, 12:14 PMallocate
be a better name and avoid the clash?simon.vergauwen
10/06/2022, 12:15 PMsimon.vergauwen
10/06/2022, 12:15 PMsimon.vergauwen
10/06/2022, 12:16 PM