KairoCloseable
is similar to Java's Closeable
, but it supports coroutines.
// build.gradle.kts
dependencies {
implementation("kairo:kairo-closeable:$kairoVersion")
}
// src/main/kotlin/yourPackage/.../YourFile.kt
class MyCloseable : KairoCloseable {
override fun close() {
// ...
}
}
MyCloseable().use { myCloseable ->
// ...
}
// src/main/kotlin/yourPackage/.../YourFile.kt
class MyCloseable : KairoCloseable.Suspend {
override suspend fun close() {
// ...
}
}
MyCloseable().use { myCloseable ->
// ...
}