Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/redux-actions

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/redux-actions

TypeScript definitions for redux-actions

  • 2.6.5
  • ts4.5
  • ts4.6
  • ts4.7
  • ts4.8
  • ts4.9
  • ts5.0
  • ts5.1
  • ts5.2
  • ts5.3
  • ts5.4
  • ts5.5
  • ts5.6
  • ts5.7
  • ts5.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is @types/redux-actions?

@types/redux-actions provides TypeScript definitions for the redux-actions library, which is used to create and handle actions in Redux applications more efficiently.

What are @types/redux-actions's main functionalities?

createAction

The createAction function allows you to create an action creator for a specific action type. In this example, an action creator for the 'INCREMENT' action type is created, which expects a payload of type number.

const increment = createAction<number>('INCREMENT');

handleAction

The handleAction function allows you to create a reducer for a specific action type. In this example, a reducer is created for the 'INCREMENT' action type, which increments the state by the action's payload.

const counter = handleAction<number, number>(increment, (state, action) => state + action.payload, 0);

combineActions

The combineActions function allows you to handle multiple action types with a single reducer. In this example, the reducer handles both 'INCREMENT' and 'RESET' action types, resetting the state to 0 when the 'RESET' action is dispatched.

const reset = createAction('RESET');
const counter = handleAction<number, number>(combineActions(increment, reset), (state, action) => action.type === 'RESET' ? 0 : state + action.payload, 0);

createActions

The createActions function allows you to create multiple action creators at once. In this example, action creators for 'INCREMENT' and 'DECREMENT' action types are created, both expecting a payload of type number.

const { increment, decrement } = createActions({
  INCREMENT: (amount: number) => amount,
  DECREMENT: (amount: number) => amount
});

handleActions

The handleActions function allows you to create a reducer that handles multiple action types. In this example, a reducer is created that handles both 'INCREMENT' and 'DECREMENT' action types, incrementing or decrementing the state by the action's payload.

const counter = handleActions<number>({
  [increment.toString()]: (state, action) => state + action.payload,
  [decrement.toString()]: (state, action) => state - action.payload
}, 0);

Other packages similar to @types/redux-actions

FAQs

Package last updated on 07 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc