tooploox / KMMSongApp

2 stars 1 forks source link

Fetch songs data from local source #4

Closed wzieba closed 4 years ago

wzieba commented 4 years ago

Interesting library to explore: https://github.com/icerockdev/moko-resources

wzieba commented 4 years ago

https://stackoverflow.com/questions/63020969/kotlin-mpp-expect-actual-with-different-signatures

General idea:

commonMain

expect class FileProvider {
    fun provideFile(): ByteArray
}

androidMain

actual class FileProvider constructor(context: Context) {
    actual fun provideFile(): ByteArray {
        return ByteArray(2137)
    }
}

Questions:

wzieba commented 4 years ago

how DI knows that it should build FileProvider from androidMain?

We have to create platform-specific DI module. We can do this also by expected/actual mechanism.

See #12 and platformSpecificModule instance for details.