#NGRX Entity style with Signals for per-record item fast update performance?

2 messages · Page 1 of 1 (latest)

hollow breach
#

How would you emulate this NGRX Entity style with Signals when you have record items having frequent updates and you don't want to recreate arrays constantly.

Typically you'd do something like this:

state = signal(
{
  1: { name: 'A', progress: 0 },
  2: { name: 'B', progress: 0 },
  3: { name: 'C', progress: 0 },
});

const data = computed(() => state()[1].progress);

But if an entity record updates its progress very very frequently that thrash unnecessary array creation.

You could split the the signal into a signal of ids: number[] and perhaps a map of signals for the entities to access, but that feels super cumbersome.

Any better ideas?

cosmic forge