nwh
07/20/2018, 7:39 PMelizarov
07/20/2018, 9:18 PMnwh
07/21/2018, 12:10 AMlaunch(DB) { /* here the context of the database is automatically available */ }
gildor
07/21/2018, 2:03 PMgroostav
07/22/2018, 10:22 PM//damn these narrow thread columns...
fun launchInDBContext(
moreContext: CoroutineContext,
block: suspend DBScope.() -> Unit): Job{
return launch(DBContext + moreContext){
val directScope = this;
val dbContext = directScope[DBContext.Key]
val modifiedDBScope = DBScope(directScope, dbContext)
newScope.block()
}
}
you can probably even make that inline
with crossinline
on the lambda.