reduxjs/angular-redux

Untrack all dispatch operations

Closed this issue · 1 comments

The read of selectedState here can end up tracked in a reactive context like an effect, if a dispatch is made inside of that context. This happens because a dispatch causes subscribers to run synchronously to receive the newly reduced state, and selectedState is read inside a subscriber.

There are 2 possible fixes here:

  1. For good reactive hygiene, ideally the wholedispatch() operation should be untracked. Nothing downstream of dispatch() makes sense to track if invoked from a reactive context.

  2. In addition to 1, linkedSignal supports equality directly so the read of selectedState in order to invoke the equality function is actually not necessary. Instead, the equality operation can be delegated to linkedSignal.

This is causing issues in a minimal repro I made here:

https://stackblitz.com/edit/stackblitz-starters-3iluayah?file=src%2Fmain.ts