Not clear how to use coroutines extensions (executeTransactionAwait)


Could you please describe how to use (or ideas behind of) kotlin-coroutines extensions?

In particular, I open realm and run executeTransactionAwait on IO dispatcher, and it throws

java.lang.IllegalStateException: Realm access from incorrect thread. Realm objects can only be accessed on the thread they were created

The code is similar to following

withContext(Dispatchers.IO) {
	openRealm().use { realm ->
		realm.executeTransactionAwait {

PS. We’re using MongoDB Realm 10.3.1 in the way that we don’t keep Realm opened, but instead for each transaction:
Open realm -> execute transaction -> close realm


Was you able to fix it? i have the same doubt

No, we have abandoned built-in extensions and use custom code