I have a helper class for doing some jobs on database Realm. As you know, we have some restriction in working with realm, such as:
- Realm instance is not auto refresh on non looping thread.
- Realm objects can only be accessed on the thread they were created
My Helper class extends CoroutineScope and to provide a CoroutineContext I used this code
Executors.newSingleThreadExecutor().asCoroutineDispatcher()
But my problem is all jobs on this CoroutineScope is running on non looping thread so
How can I create a ExecutorCoroutineDispatcher which is run on a single looper thread.
It's obvious I don't want to use Dispatchers.Main because it supposes to do jobs on my Database