Skip to content

Latest commit

 

History

History
31 lines (25 loc) · 776 Bytes

README.md

File metadata and controls

31 lines (25 loc) · 776 Bytes

A Reactive State Management for JS Application (WIP)

const { state, config } = createState(
  withEntities<Todo>(),
  withUIEntities<UIEntity>(),
  withProps<{ foo: string }>({ foo: '' })
);

const store = new Store({ state, name: 'todos', config });

class TodosRepositry {
  todos$ = store.pipe(selectAll());
  todo$ = (id) => store.pipe(selectEntity(id));

  addTodo() {
    store.reduce(
      addEntity({ id: 1, title: '' }),
      write((state) => {
        state.foo = 'newfoo';
      })
    );
  }
}
Icons made by Freepik from www.flaticon.com