tim-smart / tim-smart/effect-atom
Feature Request: Atom.kvs effectful default value
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 792
- Forks
- 49
- PR merge metrics
- No merged PRs in 30d
Description
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),
})
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating Atom.kvs and inspecting how its defaultValue is evaluated, then trace the BrowserKeyValueStore.layerLocalStorage integration shown in the example. Define how an effectful default should interact with persisted values and confirm that the resulting API can initialize and sync the flag atom.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100