russhwolf / multiplatform-settings

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

wasmJs support for multiplatform-settings-coroutines #188

Closed ahna92 closed 4 weeks ago

ahna92 commented 7 months ago

As wasm went stable, need support for multiplatform-settings-coroutines ,

Also kotlinx.coroutines supported wasm which was the blocker i think

Tired to support in https://github.com/russhwolf/multiplatform-settings/pull/187 , but i feel some configurations in BuildHelpers.kt blocked it

russhwolf commented 6 months ago

Wasm is not stable. But it is stable enough for kotlinx to include it, which is good enough for here.

Unfortunately, Turbine is also a blocker here.

There are some refactors in the 1.2 branch because the old BuildHelpers config is terrible. This will be trivial to add on top of the existing changes in 1.2.

ahna92 commented 6 months ago

Great, thanks !

armond-avanes commented 6 months ago

@russhwolf Is there any ETA for v1.2 and WASM support?

shriharsha-srb commented 6 months ago

@russhwolf Would be nice to know if this is in progress and if its gonna be released with 1.2 version. Thanks :)

xxfast commented 6 months ago

Turbine 1.1.0 now has wasmJs target

russhwolf commented 6 months ago

Been traveling and otherwise busy, but my current goal is to get this out as part of 1.2 by the end of the month.

shriharsha-srb commented 5 months ago

@russhwolf Can you plz provide some updates here ? Also let me know if some snapshot version if available. That works as well.

burnoo commented 2 months ago

@shriharsha-srb I've published snapshot of 1.2.0 to my public maven repository. Feel free to use it while waiting for official release ☺️

Setup

Add maven In settings.gradle.kts (read more about versioning here)

dependencyResolutionManagement {
    repositories {
        maven(url = "https://pkgs.dev.azure.com/burnoo/maven/_packaging/public/maven/v1") {
            content {
                includeVersionByRegex(".*", ".*", ".*-beap[0-9]+")
            }
        }
    }
}

In your module:

implementation("com.russhwolf:multiplatform-settings:1.2.0-beap1")
stephanepechard commented 1 month ago

@burnoo Thanks for releasing this!

Unfortunately, it does not work at the moment, I always get: Could not find com.russhwolf:multiplatform-settings:1.2.0-beap1. Is it still available?

burnoo commented 1 month ago

@stephanepechard

Yes it's still available. Have you added my maven to settings.gradle.kts? You can check out similar configuration here

stephanepechard commented 1 month ago

@burnoo Thanks for your answer. I have copied the exact same config, with no much luck :-(

Screenshot 2024-08-21 at 18 17 13
burnoo commented 1 month ago

I've just checked it in my local environment and maven works as expected. Could you show the rest of the file and implementation usage?

stephanepechard commented 1 month ago

@burnoo Sure, but maybe not on this thread, can I write you an email? Thanks!

kit0kat commented 1 month ago

Hi @burnoo thanks for publishing 1.2.0 !

I just added it to my project and tried to use it on wasmJs:

val settings = StorageSettings(localStorage).toFlowSettings()

But .toFlowSettings() does not work since StorageSettings does not inherit from ObservableSettings like the Android and iOS implementation.

This works on Android and iOS: val settings = SharedPreferencesSettings(sharedPreferences).toFlowSettings() val settings = NSUserDefaultsSettings(NSUserDefaults.standardUserDefaults()).toFlowSettings()

Is this already supported in 1.2.0 ?

@russhwolf Will there be an official release soon?

burnoo commented 1 month ago

Hi @kit0kat. 1.2.0 comes with the new artifact com.russhwolf:multiplatform-settings-make-observable that allows to observe StorageSettings at runtime. Important thing to mention is that it will only trigger updates for the current ObservableSettings instance (docs).

Artifact is published to my maven, so you can do the following

  1. Add com.russhwolf:multiplatform-settings-make-observable:1.2.0-beap1 to dependencies
  2. Use StorageSettings(localStorage).makeObservable().toFlowSettings()
kit0kat commented 1 month ago

@burnoo Thank you! Now it works as expected. Many thanks!

russhwolf commented 4 weeks ago

Sorry it took so long. This has now been released in version 1.2.0.