russhwolf / multiplatform-settings

A Kotlin Multiplatform library for saving simple key-value data
Apache License 2.0
1.7k stars 67 forks source link

Error using ObservableSettings on compose multiplatform no-arg WasmJs #200

Closed ronjunevaldoz closed 2 months ago

ronjunevaldoz commented 3 months ago
class LocalKeyValueStorage : TokenStorage {
    private val settings: Settings by lazy { Settings() }
    private val observableSettings: ObservableSettings by lazy { settings as ObservableSettings }
    init {
        // observableSettings
    }
}
russhwolf commented 2 months ago

Not all Settings are ObservableSettings, so it's not safe to blindly cast like that.

New in 1.2.0, you can add the multiplatform-settings-make-observable module and do val observableSettings = settings.makeObservable() instead, but note that now you will only receive updates if you observe on ObservableSettings instance where you make changes.

Otherwise, I don't think there's anything new to add here so I'm going to close this issue.