on Close
Register a callback to be invoked when this definition is closed/released. Used within withOptions { } block.
Useful for cleanup operations like closing connections, releasing resources, etc.
Parameters
on Close
Callback function that receives the instance being closed
Example:
single { DatabaseConnection() } withOptions {
onClose { connection ->
connection.close()
}
}Content copied to clipboard