createAction
createAction is a utility for defining Redux actions. It is a re-export of the createAction function from @reduxjs/toolkit.
Importing
To use createAction, import it from @blue-functor/remodel:
import { createAction } from '@blue-functor/remodel';Example Usage
src/models/users/actions.ts
import { createAction } from '@blue-functor/remodel';
// Define a simple action
export const signIn = createAction<{ username: string; password: string }>('USER/SIGN_IN');In this example:
signInis an action creator for theUSER/SIGN_INaction type.- The payload structure is defined as an object with
usernameandpasswordproperties.
Notes
createActionis a re-export of thecreateActionfunction from@reduxjs/toolkit.- It simplifies the creation of strongly-typed action creators, ensuring consistency and type safety across your application.
- Use it to define all standard actions within your models for better integration with Redux reducers and epics.