{"library":"redux-thunk-fsa","title":"Redux Thunk FSA","description":"FSA-compliant thunk middleware for Redux that extends the standard redux-thunk package to support Flux Standard Actions (FSA). Current stable version is 4.1.1, released 2024-02-15, with regular updates. It allows action creators to return functions (thunks) for asynchronous or conditional dispatching, but with the added ability to handle FSA-compliant actions where the payload contains a dispatch function. Differentiates from redux-thunk by integrating seamlessly with redux-promise for async FSA patterns. Ships TypeScript definitions and supports React Native. Maintained by Makeomatic.","language":"javascript","status":"active","last_verified":"Sat Apr 25","install":{"commands":["npm install redux-thunk-fsa"],"cli":null},"imports":["import ReduxThunk from 'redux-thunk-fsa'","import { createStore, applyMiddleware } from 'redux';\nimport ReduxThunk from 'redux-thunk-fsa';\nconst store = createStore(reducer, applyMiddleware(ReduxThunk));","import { createStore, applyMiddleware, compose } from 'redux';\nimport ReduxThunk from 'redux-thunk-fsa';\nconst store = createStore(reducer, compose(applyMiddleware(ReduxThunk), window.__REDUX_DEVTOOLS_EXTENSION__?.()));","import type { ThunkAction, ThunkDispatch } from 'redux-thunk-fsa'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { createStore, applyMiddleware } from 'redux';\nimport ReduxThunk from 'redux-thunk-fsa';\n\n// Example reducer\nfunction counter(state = 0, action) {\n  switch (action.type) {\n    case 'INCREMENT':\n      return state + 1;\n    default:\n      return state;\n  }\n}\n\n// Async action creator returning a thunk\nfunction incrementAsync() {\n  return (dispatch) => {\n    setTimeout(() => {\n      dispatch({ type: 'INCREMENT' });\n    }, 1000);\n  };\n}\n\n// Create store with thunk middleware\nconst store = createStore(counter, applyMiddleware(ReduxThunk));\n\n// Dispatch async action\nstore.dispatch(incrementAsync());\nconsole.log(store.getState()); // 0 initially, then 1 after 1 second","lang":"typescript","description":"Demonstrates basic Redux store setup with redux-thunk-fsa middleware and an async action creator returning a thunk.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}