DocsAction UtilscreateAction

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:

  • signIn is an action creator for the USER/SIGN_IN action type.
  • The payload structure is defined as an object with username and password properties.

Notes

  • createAction is a re-export of the createAction function 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.