redux-devtools icon indicating copy to clipboard operation
redux-devtools copied to clipboard

Suggestion: add filter to hide all "no-op" actions

Open markerikson opened this issue 4 years ago • 2 comments

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)

markerikson avatar Jun 04 '21 23:06 markerikson

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:

  1. Figure out the UI/UX
  2. Is strict equality good enough? Should we use Object.is instead?

FaberVitale avatar Jun 22 '21 07:06 FaberVitale

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?

Bartel-C8 avatar Jun 29 '22 12:06 Bartel-C8