NGRX Traits is a library to help you compose and reuse state logic in your angular app. There is two versions, @ngrx-traits/signals supports ngrx-signals, and @ngrx-traits/{core, common} supports ngrx.
MIT License
44
stars
3
forks
source link
Allow factory config in withEntitiesLoadingCall #95
Allow an alternative way of using withEntitiesLoadingCall, that receives a factory function like with withCalls, this has the advantage of allowing us to use the store in the onSuccess and onError
example
withEntitiesLoadingCall(({ entitiesPagedRequest, entitiesFilter, se }) => ({
fetchEntities: async () => {
const res = await lastValueFrom(
inject(BranchService).getBranches({
search: entitiesFilter().search,
skip: entitiesPagedRequest().startIndex,
take: entitiesPagedRequest().size,
}),
);
return { entities: res.resultList };
},
onSuccess: ({ entities }) => {
// call the store signals.computed or methods or patchState
}
})),
Allow an alternative way of using withEntitiesLoadingCall, that receives a factory function like with withCalls, this has the advantage of allowing us to use the store in the onSuccess and onError example
withEntitiesLoadingCall(({ entitiesPagedRequest, entitiesFilter, se }) => ({ fetchEntities: async () => { const res = await lastValueFrom( inject(BranchService).getBranches({ search: entitiesFilter().search, skip: entitiesPagedRequest().startIndex, take: entitiesPagedRequest().size, }), ); return { entities: res.resultList }; }, onSuccess: ({ entities }) => { // call the store signals.computed or methods or patchState } })),