type-regi
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

type-regi

simple event store for react/typescript.

CircleCI

type SampleState = {
    count: number;
};
type SampleActions = {
    increment: {
        value: number;
    };
};
const defaultState: SampleState = {
    count: 0
};
const actions = {
    increment(state: SampleState, payload: { value: number }) {
        const { value } = payload;
        return {
            count: state.count + value
        };
    }
};

const store = new TypeRegi<SampleState, SampleActions>(defaultState, actions);

store.subscribe((state: SampleState) => {
    console.log('count is ${state.count}.');
});

store.dispatch('increment', { value: 1 });
// => "count is 1"

Readme

Keywords

Package Sidebar

Install

npm i type-regi

Weekly Downloads

0

Version

1.1.3

License

ISC

Unpacked Size

5.21 kB

Total Files

5

Last publish

Collaborators

  • fnobi