React · Senior · Question 31 of 75
What is createListenerMiddleware in Redux Toolkit for?
- ✓Correct answer: To run side effects in response to specific actions
- 2To subscribe React components to individual store fields
- 3To listen to DOM events and turn them into Redux actions
Explanation
Listener middleware is a lightweight alternative to redux-saga and redux-observable: startListening({ actionCreator: todoAdded, effect: async (action, api) => {...} }). You can wait for other actions (take), cancel tasks, debounce, and work with state before and after the action.