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
rocketraman
04/01/2021, 2:17 PM
Just run the API calls on the
Main
dispatcher.
rocketraman
04/01/2021, 2:19 PM
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
clark
04/01/2021, 2:19 PM
Do you have a simple example?
r
rocketraman
04/01/2021, 2:20 PM
Copy code
withContext(Dispatchers.Main) {
... api calls here ...
}
👍 1
rocketraman
04/01/2021, 2:21 PM
You could look at
MainScope
also to combine that dispatcher with a SupervisorJob.