Anyone found any elegant ways to handle the main t...
# apollo-kotlin
c
Anyone found any elegant ways to handle the main thread precondition for multiplatform apollo on iOS? I would prefer to not have to create a wrapper class specifically for iOS for each of my repositories.
r
Just run the API calls on the
Main
dispatcher.
We do this for both iOS and Android and haven't had any issues. Our app is not doing a lot of background stuff though.
c
Do you have a simple example?
r
Copy code
withContext(Dispatchers.Main) {
  ... api calls here ...
}
👍 1
You could look at
MainScope
also to combine that dispatcher with a SupervisorJob.