Here is the class itself: ``` object AnalyticsConf...
# kotlin-native
g
Here is the class itself:
Copy code
object AnalyticsConfig {
    lateinit var baseUrl: String
}
b
IIRC in native, all object vars are initialized as runtime init, which is different compared to JVM (lazy). To workaround this, we do something similar like this:
Copy code
import kotlin.native.concurrent.AtomicReference
private val BASE_URL =  AtomicReference<String?>(null)
fun setBaseUrl(urlString: String) {
    BASE_URL.value = urlString.freeze()
}

actual object AnalyticsConfig {
    fun getBaseUrl() = BASE_URL.value!!
}
This requires making
AnalyticsConfig
an expect/actual class because you have to do native-specific concurrency stuff on the native side
g
Sounds like this is the way to go, thanks will try that.
@basher It worked, nice!