Hello. I’m quite new to multiplatform development....
# multiplatform
s
Hello. I’m quite new to multiplatform development. I’m seeking an advice. I want my iOS and Android app to be able to fetch a json file from network and cache it on a device for the purpose of performance. Is there a multiplatform library doing that? I would appreciate any recommendation or advice.
i
Ha! See the sample link above I posted 🙂
s
I had a quick look at the hands-on before. Using database for storing a single json file seems to be an overkill in my case. I would like to store it as it in json form. Is there another multiplatform library that stores file?
i
Ah, gotcha - that I wouldn't know, sorry
c
If it's a small JSON response, you could use multiplatform-settings to cache it in SharedPreferences/NSUserDefaults. Or you should be able to use okio's new filesystem API to write it directly to file. Alternatively, just cache it in memory in a "repository layer", using a
StateFlow
to hold onto the data and emit changes to the UI
s
Thanks for the reply. I found the two libraries before, but didn't try them, because the file to save is too big to store in the settings, and Okio doesn't seem to support iOS and tvOS yet. Does Okio work in iOS?
c
I actually don't know, I assumed it would because the docs say "Available on all platforms."...
s
I saw some note from there website that Kotlin/Native is not supported yet because they are waiting for the new memory manager.
e
You say a db is overkill and the file too big for SharedPreferences / NSUserDefaults. And memory caching isn't an option either? So file system is the only option for you? If so did you check out https://docs.korge.org/korio?
BTW setting up https://cashapp.github.io/sqldelight/ isn't too hard.
s
I haven't seen KorIO. I will look at it. Thanks. BTW, the difficulty of SQLDelight is not about setting up to me. I'm hesitant about using database because db migration is not always easy.
r
yes okio does work on ios. That's probably the best fit for what you're describing.
s
Oh, does it? That's awesome.
I'll try Okio again. Thanks guys. 👍