// unit.ts
const unit = reduxUnit(initialState, {
typePrefix: 'TODO',
prefixSeparator: ':',
separator: '-',
});
const { actions, reducer } = unit({
plainAction: state => state,
add: (state, todo: string) => ({
...state,
savedTodos: state.savedTodos.concat(todo),
}),
repeat: (state, todo: string, count: number) => ({
...state,
savedTodos: state.savedTodos.concat(todo.repeat(count)),
}),
getTodo: api<Date>()({
field: 'getTodo',
onSuccess: (dataState, todos: string[]) => ({ ...dataState, todos }),
}),
});
Use npm run dev
to start the development server(on port 3000), npm run build
to build the project.
- redux-unit: Contains all source files + async helpers.
- store.ts: Redux store setup.
- initial.ts: Initial state creation.
- unit.ts: Action creators/reducer generation with helpers.
- fatUnit.ts: Same as above, but without helpers + some other ways to do it.
- app.ts: Action creation/dispatch.