Hello everyone, how do you share resource loading ...
# mvikotlin
n
Hello everyone, how do you share resource loading between desktop and android when utilizing Decompose/MVI? To access resources on Android you need reference to resources, and to get resources you need some kind of context that you cannot seem to get in commonMain. Making a simple weather app, I have an expect/actual fun that loads imageBitmaps (from res/drawable on android, and resources/images on desktop), but for the android one I need to get access to resources from context but I cannot access context in the commonMain to pass it to the expect fun. And desktop doesn't seem to support Painter API so I have to use imageBitmaps. This seems like a common thing to share ( anything with images really), so there must be a way I am missing out on. (Architecture is the same as Jetbrains/ Todo Sample)
a
There many ways I think. One of the options is Moko Resources: https://github.com/icerockdev/moko-resources Or you can create an interface with whatever data you need and provide implementations from outside. Just one think to notice - ideally Stores should not depend on resources, but mappers/transformers/UI can depend.
n
@Arkadii Ivanov This seems to be iOS & Android, while my use case requires something for Android/Desktop?
a
Yeah, missed that part. Maybe raise an issue and they will add JVM support? Otherwise I would stick with a custom solution. I would create a common module and put Resources interface there, which would contain everything. All other modules that require resources would depend on the Resources interface.