Open ghostdogpr opened 6 years ago
it sounds very reasonable to me! I'm wondering how well it will be aligned with our general IO
effect?
The use
function takes an IO
and returns an IO
, so I guess we're still aligned?
I got the idea watching this talk: https://speakerdeck.com/iravid/boring-usecases-for-exciting-types?slide=53 (ZIO and Managed are mentioned at the end).
Hi @ghostdogpr, thank you for the link!
I think it makes total sense, but i would probably rather have it as alternative (have both apply => IO and apply => Managed), since we are trying to be as unopinionated as possible on how to use this API!
User can always do bracket
or ensuring
.
Would you like to do a pull request with a usage example? =)
Yeah, it makes sense to allow both. This one could just be a helper method in the companion object. I’ll work on a PR.
@ghostdogpr, thanks a lot!
How about using
Managed
from ZIO to avoid having users (forgetting) invokeclose
explicitly?For example:
Then when using it:
Or if we want to keep the wrapper API low-level, there could be another higher-level API that does something like that:
where the
acquire
operation would create the channel and call bind, and therelease
operation would close it.How do you think?