So in a mobile application, there is a Main Thread...
# kotlin-native
s
So in a mobile application, there is a Main Thread. It feels like Kotlin/native is encouraging me to have all my objects attached to that main thread. Ideally, I'd like to pull almost all logic off of that main thread, and leave as much time for drawing as possible to that thread, but it feels difficult to manage objects that are attached to other threads. How would you recommend that this would be done? Workers?
Let's say I've got an object that all the logic inside of it I want to run in a background thread. This seems complicated to accomplish and manage.
o
Nope, for example in code I referred above http fetch and json parsing happens on the background thread(aka async queue) and only UI manipulations happen on the main thread
s
That is kind of using a trick with objc objects though. I'm trying to figure out how to do this in shared code between Android and iOS, meaning it's in Kotlin common code.
o
Just execute in worker, describe job with shared or detached object and return results to the main thread using its queue also with frozen or detached object