Hi I am using Koltin 1.9.24. With the Spring Boot ...
# multiplatform
p
Hi I am using Koltin 1.9.24. With the Spring Boot and Kotlin JS (REACT) and wanted to take advantage of KMM as we need to share Enums as bare minimum between the two. The Enum itself I can create in common
commonMain
however specific functions that are trivial to that Enum should be supported across all (at least I know these are applicable to Kotlin JS) ex
Copy code
enum class SampleEnum (
val category: String,
val description: String
) {
A_ONE("A", "Some Desc A One"),
A_TWO("A", "Some Desc A Two"),
B_ONE("B", "Some Desc B One"),
B_TWO("B", "Some Desc B Two");

companion object {
   fun getAllPerCategoryA() = entries.filter( it.category == "A")
}
}
I see that "filter" is not supported in commonMain. And approach to create this in each source code defeats the purpose of common codebase. Is there a way to make JVM and JS Common since each one support this functionality?
j
it is supported, pass in the predicate like this: Use squigglies instead of parentheses
entries.filter { it.category == "A" }