I have a selector that returns an array. The elements in the array themselves have derived data. I essentially need a recursive memoization selector that returns a derived array composed of derived elements.
my current attempt is:
export const selectEntitesWithAssetBuffers = createSelector(
[selectSceneEntities, getAssets],
(entities, loadedAssets) => {
return entities.map((entity) => {
entity.buffers = entity.assets.map((assetName) => {
return loadedAssets[assetName].arrayBuffer;
})
return entity;
})
}
)
My concerns here are anytime entities
or loadedAssets
change this will recompute the entire list. What I'm expecting to setup is something like a selectEntityWithBuffer
that would get passed to the entities.map
. Ideally, I want this to only recompute when an entity.assets
array changes.