I would like to use MR in my BL “commonMain” to se...
# moko
m
I would like to use MR in my BL “commonMain” to set a default val, is it possible? In my Composables it works well, but in BL I am struggling… ---------------------
Copy code
mvikotlin = "3.2.0"

##########################################################################################
[libraries] # Define the libraries

###Moko
mokoResources = { group = "dev.icerock.moko", name = "resources", version.ref = "moko" }
mokoResourcesCompose = { group = "dev.icerock.moko", name = "resources-compose", version.ref = "moko" }
Copy code
@Serializable
data class BucketlistItemResponse(@SerialName(value = "item") val item: String? = null) {
  fun asRandomTask(): RandomTask {
    runBlocking {
      println(StringDesc.Resource(MR.strings.api_e_hint))
    }
    return RandomTask(
      title = "Random Task",
      description = item ?: "API Fehler"
    )
  }
}
output console:
2023-04-18 19:15:55.509 21542-21542 System.out              ---------               I  ResourceStringDesc(stringRes=StringResource(resourceId=2131558495))
1
a
hi. you can't get String from resource in shared code. on android to read String should be passed Context, on web to read string we should suspend and load files with texts, so only on UI layer you can read String from resource.
m
ok thx