-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
In #11 I outline that I do not need coroutines, and how I removed the runBlocking { ... } calls from the call-sites.
Now I've gone a bit further in cleaning up the call-sites, and I create this issue in order to share the approach (maybe it's valuable to others).
Here a before and after of what the call-site looks like:
The code that makes this:
inline fun <reified T> TerpalDriver.runQuery(stmt: Statement) =
runBlocking { this@runQuery.run(stmt.queryOf<T>()) }
inline fun <reified T> TerpalDriver.streamQuery(stmt: Statement) =
runBlocking { this@streamQuery.stream(stmt.queryOf<T>()) }
inline fun <reified T> TerpalDriver.runRawQuery(stmt: Statement) =
runBlocking { this@runRawQuery.runRaw(stmt.queryOf<T>()) }
fun TerpalDriver.runAction(stmt: Statement) =
runBlocking { this@runAction.run(stmt.action()) }
inline fun <reified T> TerpalDriver.runActionReturning(stmt: Statement) =
runBlocking { this@runActionReturning.run(stmt.actionReturning<T>()) }
fun TerpalDriver.runBatchAction(stmt: Statement) =
runBlocking { this@runBatchAction.run(stmt.action()) }
inline fun <reified T> TerpalDriver.runBatchActionReturning(stmt: Statement) =
runBlocking { this@runBatchActionReturning.run(stmt.actionReturning<T>()) }
inline fun <reified T> TerpalDriver.streamBatchActionReturning(stmt: Statement) =
runBlocking { this@streamBatchActionReturning.stream(stmt.actionReturning<T>()) }deusaquilus
Metadata
Metadata
Assignees
Labels
No labels