1.1.3 • Published 4 years ago

type-regi v1.1.3

Weekly downloads
34
License
ISC
Repository
-
Last release
4 years ago

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"
1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.4

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago