Skip to content

effector/model

Repository files navigation

Model

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).

API

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 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.

About

Effector models with ease

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Contributors 2

  •  
  •