tim-smart / tim-smart/effect-atom
Runtime without upfront layer
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 792
- Forks
- 49
- PR merge metrics
- No merged PRs in 30d
Description
I'd like to define atoms with service dependencies in a shared package and provide different layer implementations per platform (e.g. web vs native).
Currently Atom.runtime(layer) requires the layer at definition time, which couples the atom definitions to a specific implementation.
Would something like this make sense?
// core/runtime.ts - create runtime without layer
export const runtime = Atom.lazyRuntime<Api | Storage>()
// core/atoms.ts - real atoms with real dependencies, defined once
export const users = runtime.atom(Effect.flatMap(Api, a => a.getUsers()))
export const posts = runtime.atom(Effect.flatMap(Api, a => a.getPosts()))
export const userCount = Atom.make((get) => Result.map(get(users), u => u.length))
// web/main.tsx - provide layer
<RegistryProvider initialValues={[Atom.initialValue(runtime.layer, WebApiLayer)]}>
// native/main.tsx - different layer, same atoms
<RegistryProvider initialValues={[Atom.initialValue(runtime.layer, NativeApiLayer)]}>
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 reading the existing Atom.runtime implementation and the runtime-related code in core/runtime.ts and core/atoms.ts. Trace how RegistryProvider consumes Atom.initialValue, then assess whether one shared atom definition can use different web and native layers. Done means the proposed lazy runtime behavior is clearly validated for both platform entry points.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100