Skip to content

Latest commit

 

History

History

kairo-closeable

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

kairo-closeable

KairoCloseable is similar to Java's Closeable, but it supports coroutines.

Usage

Step 1: Include the dependency

// build.gradle.kts

dependencies {
  implementation("kairo:kairo-closeable:$kairoVersion")
}

Step 2: Implement and use a KairoCloseable

// src/main/kotlin/yourPackage/.../YourFile.kt

class MyCloseable : KairoCloseable {
  override fun close() {
    // ...
  }
}

MyCloseable().use { myCloseable ->
  // ...
}

Step 3: Implement and use a KairoCloseable.Suspend

// src/main/kotlin/yourPackage/.../YourFile.kt

class MyCloseable : KairoCloseable.Suspend {
  override suspend fun close() {
    // ...
  }
}

MyCloseable().use { myCloseable ->
  // ...
}