redux-devtools
redux-devtools copied to clipboard
Suggestion: add filter to hide all "no-op" actions
It's possible for actions to result in no state updates at all. Some actions are dispatched just as "signals" to middleware (common with sagas/observables). Others just get ignored by reducers.
It would be potentially useful to have a filtering option that hides actions that resulted in no state changes.
(suggested over in Reactiflux)
I've looked a bit into it, it seems that the following predicate does the job.
// inside packages/redux-devtools-inspector-monitor/
import type { Action } from 'redux';
import type { LiftedState } from '@redux-devtools/core';
type ComputedStates<S> = LiftedState<
S,
Action<unknown>,
unknown
>['computedStates'];
export function isNoopAction<S>(
actionId: number,
computedStates: ComputedStates<S>
): boolean {
return (
actionId > 0 &&
!!computedStates[actionId] &&
!!computedStates[actionId - 1] &&
computedStates[actionId].state === computedStates[actionId - 1].state
);
}
To do:
- Figure out the UI/UX
- Is strict equality good enough? Should we use
Object.isinstead?
How's this issue progressing?
I have performance issues (high cpu load), with the following error:
Application state or actions payloads are too large making Redux DevTools serialization slow and consuming a lot of memory. See https://git.io/fpcP5 on how to configure it.
I tried adding the biggest actions/states filtering to the actionSanitizer and stateSanitizer. But I think (did some tracing) they come from redux-saga. More specifically data I put in eventChannels / channels. It would be nice to be able to filter/ignore this. Would this fit the "no-op" actions?