From f58588f5b0af01da6fe6acd0c433807e49d8fac3 Mon Sep 17 00:00:00 2001 From: enima-dema Date: Tue, 8 Nov 2022 10:50:07 +0100 Subject: [PATCH] refactor: path data in data entity collections repository --- .../ngxs-data-entity-collections.repository.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/ngxs/repositories/src/ngxs-data-entity-collections/ngxs-data-entity-collections.repository.ts b/libs/ngxs/repositories/src/ngxs-data-entity-collections/ngxs-data-entity-collections.repository.ts index 6f46dfab8..6f84b059b 100644 --- a/libs/ngxs/repositories/src/ngxs-data-entity-collections/ngxs-data-entity-collections.repository.ts +++ b/libs/ngxs/repositories/src/ngxs-data-entity-collections/ngxs-data-entity-collections.repository.ts @@ -179,6 +179,11 @@ export abstract class AbstractNgxsDataEntityCollectionsRepository< this.setEntitiesState(this.getState()); } + @DataAction() + public patchState(@Payload('patchValue') value: Partial>): void { + this.ctx.patchState(value); + } + public setComparator(comparator: EntityComparator | null): this { this.comparator = comparator; @@ -350,7 +355,7 @@ export abstract class AbstractNgxsDataEntityCollectionsRepository< protected setEntitiesState(state: EntityCollections): void { const ids: K[] = this.sortKeysByComparator(state.ids, state.entities); - this.ctx.setState({ ...state, ids, entities: state.entities }); + this.ctx.patchState({ ...state, ids, entities: state.entities }); } protected sortKeysByComparator(originalIds: K[], entities: EntityDictionary): K[] {