https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
j

Jan Stoltman

04/05/2019, 3:54 PM
Hello guys, friday afternoon question. I'm building and iOS app with kotlin multiplatform, coroutines, ktor and kotlinx.serialization and I'm having a problem with serializing huge json files (like mbs huge). As I'm using ktor I have to use coroutines to handle the
suspend
functions, this means that I'm restricted to using the UI dispatcher (afaik there is no IO dispatcher for mpp projects?). Everything worked just fine with small files, but when I try to parse this huge json my app freezes. It happens with any CPU-intense operation really. I've figured out that I could use
concurrent.Worker
for CPU-intense operations, as it doesn't block my UI. But I just cannot figure out how to join coroutines and workers, things just explode when I try to launch either one inside the other. Is there a way to get a json file from ktor, inside a coroutine, and then process it with workers? Do you guys have any recommendations? Any ideas for a direction which I could take?
4 Views