I'm trying to add a dynamic listener middleware with RTK but it does not seem to intercept actions.I use the special addListener action which by the docs should allow inject dynamic middleware from a React component.On Redux dev tools I see listenerMiddleware/add action logged, but after that I see no actions intercepted by the middleware.
import { addListener} from '@reduxjs/toolkit';
import { useDispatch } from 'react-redux';
const App = () => {
const dispatch = useDispatch();
useEffect(() => {
const unsubscribe = dispatch(
addListener({
predicate: () => {
return true;
},
effect: async (action, listenerApi) => {
console.log('log', action);
},
})
);
return () => unsubscribe();
}, [])
}