https://github.com/effector/model
Effector models with ease
https://github.com/effector/model
Last synced: about 1 year ago
JSON representation
Effector models with ease
- Host: GitHub
- URL: https://github.com/effector/model
- Owner: effector
- Created: 2024-08-10T22:48:06.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-22T14:09:29.000Z (over 1 year ago)
- Last Synced: 2024-11-07T00:19:24.669Z (over 1 year ago)
- Language: TypeScript
- Size: 701 KB
- Stars: 7
- Watchers: 12
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# Model
Effector models with ease
Work in progress, api may change
## API
```ts
import { keyval } from '@effector/model';
const entities = keyval(() => {
const $id = createStore(0);
const $count = createStore(0);
const inc = createEvent();
$count.on(inc, (x) => x + 1);
const onMount = 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;
```
## Maintains
### Getting started
- 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`
- fill in changes via `pnpm changes`
- open a PR
- enjoy 🎉
### Release workflow
Releases of Model are automated by [changesets](https://github.com/changesets/changesets) and GitHub Actions. Your only duty is creating changeset for every PR, it is controlled by [Changes-action](./.github/workflows/changes.yml).
After merging PR to master-branch, [Version-action](./.github/workflows/version.yml) will update special PR with the next release. To publish this release, just merge special PR and wait, [Release-action](./.github/workflows/release.yml) will publish packages.