ngrx-traits
ngrx-traits copied to clipboard
Multiple withEntities and withEntitiesLocalFilter breaks signalStoreFeature
When creating a reusable signalStoreFeature and adding multiple withEntities, If I need to use a withEntitiesLocalFilter for one of the entities, signalStoreFeature is broken.
example that doesn't work:
const entity = type<Product>();
const collection1 = 'product';
const entity2 = type<{ otherField: boolean }>();
const collection2 = 'product2';
const withFeature = () =>
signalStoreFeature(
withEntities({ entity, collection: collection1 }),
withEntities({ entity: entity2, collection: collection2 }),
withEntitiesLocalFilter({
entity,
collection: collection1,
defaultFilter: { test: 'test' },
defaultDebounce: 0,
filterFn: (entity, filter) => true,
})
);
if I move the withEntitiesLocalFilter next to the corresponding withEntities it works:
const entity = type<Product>();
const collection1 = 'product';
const entity2 = type<{ otherField: boolean }>();
const collection2 = 'product2';
const withFeature = () =>
signalStoreFeature(
withEntities({ entity, collection: collection1 }),
withEntitiesLocalFilter({
entity,
collection: collection1,
defaultFilter: { test: 'test' },
defaultDebounce: 0,
filterFn: (entity, filter) => true,
})
withEntities({ entity: entity2, collection: collection2 }),
);