Rick
06/05/2020, 11:10 AMtransactionAwait
: "suspend function can be called only within coroutine body".
callRealmSuspend { realm ->
realm.transactionAwait {
realm.delete(RegionRealmObject::class.java)
realm.delete(ServiceRealmObject::class.java)
}
}
and my callRealmSuspend
function looks like this:
suspend fun callRealmSuspend(call: (realm: Realm) -> Unit): Realm? {
var realm: Realm? = null
try {
realm = Realm.getDefaultInstance()
call(realm)
} catch (error: java.lang.Exception) {
LogHelper.e(messages = *arrayOf("Unhandled error occurred: ${error.localizedMessage}."))
}
return realm
}
so how do I change callRealmSuspend
function to fix the error/ provide a coroutine body? thanks!Tijl
06/05/2020, 11:13 AMcall: *suspend* (realm: Realm) -> Unit)
Rick
06/05/2020, 11:16 AMstreetsofboston
06/05/2020, 1:44 PMinline
, since you call the call
lambda directly from the callReamSuspend
function.Rick
06/05/2020, 4:57 PM