Effector models with ease
Work in progress, api may change
The goal of this project is to implement the concept of models in the effector. This requires a lot of experimentation and fresh ideas, so if you don't see commits in this repo for a long time, it means we're testing what we've come up with on real projects (this is critical if we want to achieve a truly user-friendly API).
UPD 24.12.25: We've finally found the key ideas we needed. Expect a new (significantly different) implementation in the coming months. The current API is usable, you just need the understanding that an important update is coming soon.
Stay tuned!
import{keyval}from'@effector/model';constentities=keyval(()=>{const$id=createStore(0);const$count=createStore(0);constinc=createEvent();$count.on(inc,(x)=>x+1);constonMount=createEvent();return{state: {id: $id,count: $count,},api: { inc },key: 'id',optional: ['count'],
onMount,};});entities.edit.add({id: 1});entities.edit.add([{id: 2,count: 10}]);entities.api.inc({key: 1,value: undefined});entities.$items;- clone repo
- install deps via
pnpm install - make changes
- make sure that your changes is passing checks:
- run tests via
pnpm test - run type tests via
pnpm test:types - run linter via
pnpm lint - try to build it via
pnpm build - format code via
pnpm format
- run tests via
- fill in changes via
pnpm changes - open a PR
- enjoy 🎉
Releases of Model are automated by changesets and GitHub Actions. Your only duty is creating changeset for every PR, it is controlled by Changes-action.
After merging PR to master-branch, Version-action will update special PR with the next release. To publish this release, just merge special PR and wait, Release-action will publish packages.