Skip to content

feat: Enable Web support (JS/Wasm) for multiplatform-settings-datastore #246

Description

@terrakok

Motivation

Starting in recent versions, Google has released Web-compatible artifacts for Jetpack DataStore:

  • androidx.datastore:datastore-core-wasm-js
  • androidx.datastore:datastore-preferences-core-wasm-js
  • androidx.datastore:datastore-core-okio-wasm-js (likely using Okio for cross-platform IO)

Currently, the multiplatform-settings-datastore module is restricted to non web platforms. However, since the underlying DataStore library now supports Web (via Okio/Wasm), multiplatform-settings should be able to expose this functionality.

Proposed Solution

I propose updating the multiplatform-settings-datastore module to include JS and Wasm targets.

Since multiplatform-settings acts as a wrapper around androidx.datastore, it should be sufficient to:

  1. Add the wasm-js and js artifacts from the androidx.datastore ecosystem to the module's dependencies.
  2. Ensure the backend configuration allows these targets to use the Okio-based implementation.

This would allow Web developers to use the type-safe ProtoBuf API of DataStore, just like Android/iOS and Desktop developers, without needing to switch to the basic Key-Value preferences module.

Why this is needed

Web developers currently lose the benefits of Protocol Buffers and Flow-based reactive streams when using multiplatform-settings. By leveraging the new Google Web artifacts, we can provide a consistent API across all platforms (Android, iOS, Desktop, Web).

Additional context

If the current implementation relies on file-based storage, the new okio-wasm-js artifacts seem to provide the necessary abstraction to make this work on Web (likely mapping to IndexedDB).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions