Skip to content

Feature Request: Atom.kvs effectful default value #370

@florianbepunkt

Description

@florianbepunkt

I have some atoms that I would like to sync with local storage, but their initial value is effectful. I'm looking for a way to persist the value, but Atom.kvs requires a non-effectful default.

const runtime = Atom.runtime(BrowserKeyValueStore.layerLocalStorage)

const flagAtom = Atom.kvs({
  runtime: runtime,
  key: "flag",
  schema: Schema.Boolean,
  defaultValue: () => Effect.succed(false),
})

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