russhwolf / multiplatform-settings

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

Stabilize listener APIs #34

Closed russhwolf closed 2 years ago

russhwolf commented 4 years ago

Looking for user feedback before removing the @ExperimentalListener annotation and treating listeners at the same level of stability as the rest of the library.

Note one currently-unpublished change which is visible in master: Settings.removeListener() has been replaced with listener.deactivate(). This cleans up the listener internals a little since previously, you could pass a listener to a settings instance which hadn't created it, which might lead to unexpected (usually no-op) behavior.

No specific timeline on this yet, but I want to have an issue to track what work remains before stabilizing

russhwolf commented 3 years ago

I'm planning to add typed listeners as part of 0.7 since there fairly straightforward to include as extension functions on top of the existing API and a bit more natural to use. This will let you do

settings.addIntListener("key") { int -> ... }

instead of

settings.addListener("key") {
    val int = settings.getInt("key")
    ...
}

Still looking for feedback to make sure everything is hitting people's needs before dropping the experimental annotation.

russhwolf commented 2 years ago

Ahead of a 1.0 release, I'm planning to migrate the typed listeners to being part of the ObservableSettings interface rather than being extension functions, and deprecate/remove the untyped addListener(). This will make it easier to align the APIs of ObservableSettings and FlowSettings. I'd then like to drop the @ExperimentalSettingsApi annotations from these APIs in 1.0 which will close this issue.

russhwolf commented 2 years ago

These APIs are no longer marked experimental in 1.0.0-alpha01