diff --git a/apps/example-app/src/app/examples/signals/infinete-scroll-page/components/products-branch-dropdown/products-branch.store.ts b/apps/example-app/src/app/examples/signals/infinete-scroll-page/components/products-branch-dropdown/products-branch.store.ts
index 22b7e55c..00aefb99 100644
--- a/apps/example-app/src/app/examples/signals/infinete-scroll-page/components/products-branch-dropdown/products-branch.store.ts
+++ b/apps/example-app/src/app/examples/signals/infinete-scroll-page/components/products-branch-dropdown/products-branch.store.ts
@@ -42,37 +42,3 @@ export const ProductsBranchStore = signalStore(
}),
withLogger('branchStore'),
);
-// const collection = 'products';
-// export const ProductsBranchStore2 = signalStore(
-// withEntities({
-// entity,
-// collection,
-// }),
-// withCallStatus({ initialValue: 'loading', collection }),
-// withEntitiesRemoteFilter({
-// entity,
-// defaultFilter: { search: '' },
-// collection,
-// }),
-// withEntitiesRemoteScrollPagination({
-// bufferSize: 30,
-// entity,
-// collection,
-// }),
-// withEntitiesLoadingCall({
-// collection,
-// fetchEntities: async ({ productsRequest, productsFilter }) => {
-// const res = await lastValueFrom(
-// inject(BranchService).getBranches({
-// search: productsFilter().search,
-// skip: productsRequest().startIndex,
-// take: productsRequest().size,
-// }),
-// );
-// return { entities: res.resultList, total: res.total };
-// },
-// }),
-// withLogger('branchStore'),
-// );
-// const store = new ProductsBranchStore2();
-// getInfiniteScrollDataSource({ store, collection, entity });
diff --git a/apps/example-app/src/app/examples/signals/product-list-paginated-page/product.store.ts b/apps/example-app/src/app/examples/signals/product-list-paginated-page/product.store.ts
index 307d6675..a93baa35 100644
--- a/apps/example-app/src/app/examples/signals/product-list-paginated-page/product.store.ts
+++ b/apps/example-app/src/app/examples/signals/product-list-paginated-page/product.store.ts
@@ -37,11 +37,6 @@ export const ProductsRemoteStore = signalStore(
pageSize: 5,
pagesToCache: 2,
}),
- // withEntitiesRemoteScrollPagination({
- // bufferSize: 5,
- // collection,
- // entity
- // }),
withEntitiesRemoteSort({
entity,
collection,
diff --git a/libs/ngrx-traits/signals/api-docs.md b/libs/ngrx-traits/signals/api-docs.md
index 517e1724..bc1c1433 100644
--- a/libs/ngrx-traits/signals/api-docs.md
+++ b/libs/ngrx-traits/signals/api-docs.md
@@ -17,29 +17,31 @@ and store the result of the call
withEntitiesLocalFilter(config)
Generates necessary state, computed and methods for locally filtering entities in the store,
the generated filter[collenction]Entities method will filter the entities based on the filter function
-and is debounced by default. Requires withEntities to be used.
+and is debounced by default.
+Requires withEntities to be used.
withEntitiesRemoteFilter(config)
Generates necessary state, computed and methods for remotely filtering entities in the store,
the generated filter[collection]Entities method will filter the entities by calling set[collection]Loading()
and you should either create an effect that listens toe [collection]Loading can call the api with the [collection]Filter params
or use withEntitiesLoadingCall to call the api with the [collection]Filter params
-and is debounced by default. Requires withEntities and withCallStatus to be present before this function.
+and is debounced by default.
+Requires withEntities and withCallStatus to be present before this function.
withEntitiesLoadingCall(config)
Generates a onInit hook that fetches entities from a remote source
when the [collection]Loading is true, by calling the fetchEntities function
and if successful, it will call set[Collection]Loaded and also set the entities
to the store using the setAllEntities method or the setEntitiesResult method
if it exists (comes from withEntitiesRemotePagination),
-if an error occurs it will set the error to the store using set[Collection]Error with the error.
-Requires withEntities and withCallStatus to be present in the store.
+if an error occurs it will set the error to the store using set[Collection]Error with the error.
+Requires withEntities and withCallStatus to be present in the store.
withEntitiesLocalPagination(config)
-Generates necessary state, computed and methods for local pagination of entities in the store.
-Requires withEntities to be present in the store.
+Generates necessary state, computed and methods for local pagination of entities in the store.
+Requires withEntities to be present in the store.
withEntitiesRemotePagination(config)
Generates necessary state, computed and methods for remote pagination of entities in the store.
When the page changes, it will try to load the current page from cache if it's not present,
it will call set[collection]Loading(), and you should either create an effect that listens to [collection]Loading
-and call the api with the [collection]PagedRequest params and use set[Collection]LoadResult to set the result
+and call the api with the [collection]PagedRequest params and use set[Collection]Result to set the result
and changing the status errors manually
or use withEntitiesLoadingCall to call the api with the [collection]PagedRequest params which handles setting
the result and errors automatically. Requires withEntities and withCallStatus to be used.
@@ -50,26 +52,34 @@ different between this and withEntitiesRemotePagination this will can only got t
of entities keeps growing, ideally for implementing infinite scroll style ui.
When the page changes, it will try to load the current page from cache if it's not present,
it will call set[collection]Loading(), and you should either create an effect that listens to is[Collection]Loading
-and call the api with the [collection]PagedRequest params and use set[Collection]LoadResult to set the result
+and call the api with the [collection]PagedRequest params and use set[Collection]Result to set the result
and changing the status errors manually
or use withEntitiesLoadingCall to call the api with the [collection]PagedRequest params which handles setting
-the result and errors automatically. Requires withEntities and withCallStatus to be used.
-Requires withEntities and withCallStatus to be present in the store.
+the result and errors automatically. Requires withEntities and withCallStatus to be used.
+The generated set[Collection]Result method will append the entities to the cache of entities,
+it requires either just set of requested entities set[Collection]Result({ entities }) in which case it will assume there is no more result if you set less entities
+than the requested buffer size, or you can provide an extra param to the entities, total set[Collection]Result({ entities, total }) so it calculates if there is more
+or a hasMore param set[Collection]Result({entities, hasMore}) that you can set to false to indicate the end of the entities.
+Requires withEntities and withCallStatus to be present in the store.
withEntitiesMultiSelection(config)
Generates state, signals and methods for multi selection of entities.
Warning: isAll[Collection]Selected and toggleSelectAll[Collection] wont work
-correctly in using remote pagination, because they cant select all the data
+correctly in using remote pagination, because they cant select all the data.
+Requires withEntities to be used before this feature.
withEntitiesSingleSelection(config)
-Generates state, computed and methods for single selection of entities. Requires withEntities to be present before this function.
+Generates state, computed and methods for single selection of entities.
+Requires withEntities to be present before this function.
withEntitiesLocalSort(config)
-Generates necessary state, computed and methods for sorting locally entities in the store. Requires withEntities to be present before this function
+Generates necessary state, computed and methods for sorting locally entities in the store.
+Requires withEntities to be present before this function
withEntitiesRemoteSort(config)
Generates state, signals, and methods to sort entities remotely. When the sort method is called it will store the sort
and call set[Collection]Loading, and you should either create an effect that listens to [collection]Loading
-and call the api with the [collection]Sort params and use wither setAllEntities if is not paginated or set[Collection]LoadResult if is paginated
+and call the api with the [collection]Sort params and use wither setAllEntities if is not paginated or set[Collection]Result if is paginated
with the sorted result that come from the backend, plus changing the status and set errors is needed.
or use withEntitiesLoadingCall to call the api with the [collection]Sort params which handles setting
-the result and errors automatically. Requires withEntities and withCallStatus to be present before this function.
+the result and errors automatically.
+Requires withEntities and withCallStatus to be present before this function.
withEventHandler(eventHandlerFactory)
Adds an event handler to the store, allowing the store to listen to events and react to them.
This helps with the communications between different store feature functions, normally a store feature can only
@@ -176,7 +186,8 @@ withCalls(({ productsSelectedEntity }) => ({
## withEntitiesLocalFilter(config)
Generates necessary state, computed and methods for locally filtering entities in the store,
the generated filter[collenction]Entities method will filter the entities based on the filter function
-and is debounced by default. Requires withEntities to be used.
+and is debounced by default.
+Requires withEntities to be used.
**Kind**: global function
@@ -222,7 +233,8 @@ const store = signalStore(
the generated filter[collection]Entities method will filter the entities by calling set[collection]Loading()
and you should either create an effect that listens toe [collection]Loading can call the api with the [collection]Filter params
or use withEntitiesLoadingCall to call the api with the [collection]Filter params
-and is debounced by default. Requires withEntities and withCallStatus to be present before this function.
+and is debounced by default.
+Requires withEntities and withCallStatus to be present before this function.
**Kind**: global function
@@ -302,8 +314,8 @@ when the [collection]Loading is true, by calling the fetchEntities function
and if successful, it will call set[Collection]Loaded and also set the entities
to the store using the setAllEntities method or the setEntitiesResult method
if it exists (comes from withEntitiesRemotePagination),
-if an error occurs it will set the error to the store using set[Collection]Error with the error.
-Requires withEntities and withCallStatus to be present in the store.
+if an error occurs it will set the error to the store using set[Collection]Error with the error.
+Requires withEntities and withCallStatus to be present in the store.
**Kind**: global function
@@ -364,8 +376,8 @@ export const ProductsRemoteStore = signalStore(
## withEntitiesLocalPagination(config)
-Generates necessary state, computed and methods for local pagination of entities in the store.
-Requires withEntities to be present in the store.
+Generates necessary state, computed and methods for local pagination of entities in the store.
+Requires withEntities to be present in the store.
**Kind**: global function
@@ -404,7 +416,7 @@ export const ProductsLocalStore = signalStore(
Generates necessary state, computed and methods for remote pagination of entities in the store.
When the page changes, it will try to load the current page from cache if it's not present,
it will call set[collection]Loading(), and you should either create an effect that listens to [collection]Loading
-and call the api with the [collection]PagedRequest params and use set[Collection]LoadResult to set the result
+and call the api with the [collection]PagedRequest params and use set[Collection]Result to set the result
and changing the status errors manually
or use withEntitiesLoadingCall to call the api with the [collection]PagedRequest params which handles setting
the result and errors automatically. Requires withEntities and withCallStatus to be used.
@@ -455,7 +467,7 @@ export const store = signalStore(
},
}),
// withEntitiesLoadingCall is the same as doing the following:
-// withHooks(({ productsLoading, setProductsError, setProductsLoadResult, ...state }) => ({
+// withHooks(({ productsLoading, setProductsError, setProductsResult, ...state }) => ({
// onInit: async () => {
// effect(() => {
// if (isProductsLoading()) {
@@ -469,7 +481,7 @@ export const store = signalStore(
// tap((res) =>
// patchState(
// state,
-// setProductsLoadResult(res.resultList, res.total),
+// setProductsResult({ entities: res.resultList, total: res.total } ),
// ),
// ),
// catchError((error) => {
@@ -489,7 +501,7 @@ export const store = signalStore(
store.productsPagedRequest // { startIndex: number, size: number, page: number }
// generates the following methods
store.loadProductsPage({ pageIndex: number, forceLoad?: boolean }) // loads the page and sets the requestPage to the pageIndex
- store.setProductsLoadResult(entities: Product[], total: number) // appends the entities to the cache of entities and total
+ store.setProductsResult(entities: Product[], total: number) // appends the entities to the cache of entities and total
```
@@ -499,11 +511,15 @@ different between this and withEntitiesRemotePagination this will can only got t
of entities keeps growing, ideally for implementing infinite scroll style ui.
When the page changes, it will try to load the current page from cache if it's not present,
it will call set[collection]Loading(), and you should either create an effect that listens to is[Collection]Loading
-and call the api with the [collection]PagedRequest params and use set[Collection]LoadResult to set the result
+and call the api with the [collection]PagedRequest params and use set[Collection]Result to set the result
and changing the status errors manually
or use withEntitiesLoadingCall to call the api with the [collection]PagedRequest params which handles setting
-the result and errors automatically. Requires withEntities and withCallStatus to be used.
-Requires withEntities and withCallStatus to be present in the store.
+the result and errors automatically. Requires withEntities and withCallStatus to be used.
+The generated set[Collection]Result method will append the entities to the cache of entities,
+it requires either just set of requested entities set[Collection]Result({ entities }) in which case it will assume there is no more result if you set less entities
+than the requested buffer size, or you can provide an extra param to the entities, total set[Collection]Result({ entities, total }) so it calculates if there is more
+or a hasMore param set[Collection]Result({entities, hasMore}) that you can set to false to indicate the end of the entities.
+Requires withEntities and withCallStatus to be present in the store.
**Kind**: global function
@@ -548,7 +564,7 @@ export const store = signalStore(
},
}),
// withEntitiesLoadingCall is the same as doing the following:
-// withHooks(({ productsLoading, setProductsError, setProductsLoadResult, ...state }) => ({
+// withHooks(({ productsLoading, setProductsError, setProductsResult, ...state }) => ({
// onInit: async () => {
// effect(() => {
// if (isProductsLoading()) {
@@ -562,7 +578,8 @@ export const store = signalStore(
// tap((res) =>
// patchState(
// state,
-// setProductsLoadResult(res.resultList, res.total),
+// // total is not required, you can use hasMore or none see docs
+// setProductsResult({ entities: res.resultList, total: res.total } ),
// ),
// ),
// catchError((error) => {
@@ -578,7 +595,7 @@ export const store = signalStore(
// in your component add
store = inject(ProductsRemoteStore);
- dataSource = getInfiniteScrollDataSource(store, { collecrion: 'products' }) // pass this to your cdkVirtualFor see examples section
+ dataSource = getInfiniteScrollDataSource(store, { collection: 'products' }) // pass this to your cdkVirtualFor see examples section
// generates the following signals
store.productsPagination // { currentPage: number, requestPage: number, bufferSize: 5, total: number, pagesToCache: number, cache: { start: number, end: number } } used internally
// generates the following computed signals
@@ -588,14 +605,15 @@ export const store = signalStore(
store.loadProductsNextPage() // loads next page
store.loadProductsPreviousPage() // loads previous page
store.loadProductsFirstPage() // loads first page
- store.setProductsLoadResult(entities: Product[], total: number) // appends the entities to the cache of entities and total
+ store.setProductsResult(entities: Product[], total: number) // appends the entities to the cache of entities and total
```
## withEntitiesMultiSelection(config)
Generates state, signals and methods for multi selection of entities.
Warning: isAll[Collection]Selected and toggleSelectAll[Collection] wont work
-correctly in using remote pagination, because they cant select all the data
+correctly in using remote pagination, because they cant select all the data.
+Requires withEntities to be used before this feature.
**Kind**: global function
@@ -629,7 +647,8 @@ store.toggleSelectAllProducts // () => void;
## withEntitiesSingleSelection(config)
-Generates state, computed and methods for single selection of entities. Requires withEntities to be present before this function.
+Generates state, computed and methods for single selection of entities.
+Requires withEntities to be present before this function.
**Kind**: global function
@@ -667,7 +686,8 @@ export const store = signalStore(
## withEntitiesLocalSort(config)
-Generates necessary state, computed and methods for sorting locally entities in the store. Requires withEntities to be present before this function
+Generates necessary state, computed and methods for sorting locally entities in the store.
+Requires withEntities to be present before this function
**Kind**: global function
@@ -701,10 +721,11 @@ store.sortProductsEntities({ sort: { field: 'name', direction: 'asc' } }) - sort
## withEntitiesRemoteSort(config)
Generates state, signals, and methods to sort entities remotely. When the sort method is called it will store the sort
and call set[Collection]Loading, and you should either create an effect that listens to [collection]Loading
-and call the api with the [collection]Sort params and use wither setAllEntities if is not paginated or set[Collection]LoadResult if is paginated
+and call the api with the [collection]Sort params and use wither setAllEntities if is not paginated or set[Collection]Result if is paginated
with the sorted result that come from the backend, plus changing the status and set errors is needed.
or use withEntitiesLoadingCall to call the api with the [collection]Sort params which handles setting
-the result and errors automatically. Requires withEntities and withCallStatus to be present before this function.
+the result and errors automatically.
+Requires withEntities and withCallStatus to be present before this function.
**Kind**: global function
diff --git a/libs/ngrx-traits/signals/src/lib/with-entities-filter/with-entities-local-filter.ts b/libs/ngrx-traits/signals/src/lib/with-entities-filter/with-entities-local-filter.ts
index a7b8c09b..6681a3d6 100644
--- a/libs/ngrx-traits/signals/src/lib/with-entities-filter/with-entities-local-filter.ts
+++ b/libs/ngrx-traits/signals/src/lib/with-entities-filter/with-entities-local-filter.ts
@@ -39,7 +39,9 @@ import {
/**
* Generates necessary state, computed and methods for locally filtering entities in the store,
* the generated filter[collenction]Entities method will filter the entities based on the filter function
- * and is debounced by default. Requires withEntities to be used.
+ * and is debounced by default.
+ *
+ * Requires withEntities to be used.
*
* @param config
* @param config.filterFn - The function that will be used to filter the entities
@@ -65,7 +67,7 @@ import {
* }),
* );
*
- * // generates the following signals
+ * // generates the following signals
* store.productsFilter // { search: string }
* // generates the following computed signals
* store.isProductsFilterChanged // boolean
@@ -95,7 +97,9 @@ export function withEntitiesLocalFilter<
/**
* Generates necessary state, computed and methods for locally filtering entities in the store,
* the generated filter[collenction]Entities method will filter the entities based on the filter function
- * and is debounced by default. Requires withEntities to be used.
+ * and is debounced by default.
+ *
+ * Requires withEntities to be used.
*
* @param config
* @param config.filterFn - The function that will be used to filter the entities
@@ -155,6 +159,7 @@ export function withEntitiesLocalFilter<
methods: NamedEntitiesFilterMethods;
}
>;
+
export function withEntitiesLocalFilter<
Entity extends { id: string | number },
Collection extends string,
diff --git a/libs/ngrx-traits/signals/src/lib/with-entities-filter/with-entities-remote-filter.ts b/libs/ngrx-traits/signals/src/lib/with-entities-filter/with-entities-remote-filter.ts
index 3a75893b..dfffd726 100644
--- a/libs/ngrx-traits/signals/src/lib/with-entities-filter/with-entities-remote-filter.ts
+++ b/libs/ngrx-traits/signals/src/lib/with-entities-filter/with-entities-remote-filter.ts
@@ -42,7 +42,9 @@ import {
* the generated filter[collection]Entities method will filter the entities by calling set[collection]Loading()
* and you should either create an effect that listens toe [collection]Loading can call the api with the [collection]Filter params
* or use withEntitiesLoadingCall to call the api with the [collection]Filter params
- * and is debounced by default. Requires withEntities and withCallStatus to be present before this function.
+ * and is debounced by default.
+ *
+ * Requires withEntities and withCallStatus to be present before this function.
* @param config
* @param config.defaultFilter - The default filter to be used
* @param config.entity - The entity type to be used
@@ -79,9 +81,9 @@ import {
* // effect(() => {
* // if (isProductsLoading()) {
* // inject(ProductService)
- * // .getProducts({
+ * // .getProducts({
* // search: productsFilter().name,
- * // })
+ * // })
* // .pipe(
* // takeUntilDestroyed(),
* // tap((res) =>
@@ -131,7 +133,9 @@ export function withEntitiesRemoteFilter<
* the generated filter[collection]Entities method will filter the entities by calling set[collection]Loading()
* and you should either create an effect that listens toe [collection]Loading can call the api with the [collection]Filter params
* or use withEntitiesLoadingCall to call the api with the [collection]Filter params
- * and is debounced by default. Requires withEntities and withCallStatus to be present before this function.
+ * and is debounced by default.
+ *
+ * Requires withEntities and withCallStatus to be present before this function.
* @param config
* @param config.defaultFilter - The default filter to be used
* @param config.entity - The entity type to be used
diff --git a/libs/ngrx-traits/signals/src/lib/with-entities-loading-call/with-entities-loading-call.spec.ts b/libs/ngrx-traits/signals/src/lib/with-entities-loading-call/with-entities-loading-call.spec.ts
index 682f1a0e..b4d3fc42 100644
--- a/libs/ngrx-traits/signals/src/lib/with-entities-loading-call/with-entities-loading-call.spec.ts
+++ b/libs/ngrx-traits/signals/src/lib/with-entities-loading-call/with-entities-loading-call.spec.ts
@@ -151,7 +151,7 @@ describe('withEntitiesLoadingCall', () => {
});
}));
- it('should set[Collection]LoadResult if fetchEntities returns an a {entities: Entity[], total: number} ', fakeAsync(() => {
+ it('should set[Collection]Result if fetchEntities returns an a {entities: Entity[], total: number} ', fakeAsync(() => {
TestBed.runInInjectionContext(() => {
const Store = signalStore(
withEntities({
diff --git a/libs/ngrx-traits/signals/src/lib/with-entities-loading-call/with-entities-loading-call.ts b/libs/ngrx-traits/signals/src/lib/with-entities-loading-call/with-entities-loading-call.ts
index 28c26455..2042304d 100644
--- a/libs/ngrx-traits/signals/src/lib/with-entities-loading-call/with-entities-loading-call.ts
+++ b/libs/ngrx-traits/signals/src/lib/with-entities-loading-call/with-entities-loading-call.ts
@@ -62,7 +62,9 @@ import { getWithEntitiesRemotePaginationKeys } from '../with-entities-pagination
* to the store using the setAllEntities method or the setEntitiesResult method
* if it exists (comes from withEntitiesRemotePagination),
* if an error occurs it will set the error to the store using set[Collection]Error with the error.
+ *
* Requires withEntities and withCallStatus to be present in the store.
+ *
* @param config - Configuration object
* @param config.fetchEntities - A function that fetches the entities from a remote source the return type
* @param config.collection - The collection name
@@ -156,7 +158,9 @@ export function withEntitiesLoadingCall<
* to the store using the setAllEntities method or the setEntitiesResult method
* if it exists (comes from withEntitiesRemotePagination),
* if an error occurs it will set the error to the store using set[Collection]Error with the error.
+ *
* Requires withEntities and withCallStatus to be present in the store.
+ *
* @param config - Configuration object
* @param config.fetchEntities - A function that fetches the entities from a remote source the return type
* @param config.collection - The collection name
diff --git a/libs/ngrx-traits/signals/src/lib/with-entities-pagination/with-entities-local-pagination.ts b/libs/ngrx-traits/signals/src/lib/with-entities-pagination/with-entities-local-pagination.ts
index ba11a96b..c664715e 100644
--- a/libs/ngrx-traits/signals/src/lib/with-entities-pagination/with-entities-local-pagination.ts
+++ b/libs/ngrx-traits/signals/src/lib/with-entities-pagination/with-entities-local-pagination.ts
@@ -36,6 +36,7 @@ import {
/**
* Generates necessary state, computed and methods for local pagination of entities in the store.
+ *
* Requires withEntities to be present in the store.
* @param config
* @param config.pageSize - The number of entities to show per page
@@ -54,7 +55,7 @@ import {
* entity,
* collection,
* pageSize: 5,
- * }));
+ * }),
*
* // generates the following signals
* store.productsPagination // { currentPage: 0, pageSize: 5 }
@@ -83,6 +84,7 @@ export function withEntitiesLocalPagination<
>;
/**
* Generates necessary state, computed and methods for local pagination of entities in the store.
+ *
* Requires withEntities to be present in the store.
* @param config
* @param config.pageSize - The number of entities to show per page
diff --git a/libs/ngrx-traits/signals/src/lib/with-entities-pagination/with-entities-remote-pagination.ts b/libs/ngrx-traits/signals/src/lib/with-entities-pagination/with-entities-remote-pagination.ts
index 53876a06..c5e8604b 100644
--- a/libs/ngrx-traits/signals/src/lib/with-entities-pagination/with-entities-remote-pagination.ts
+++ b/libs/ngrx-traits/signals/src/lib/with-entities-pagination/with-entities-remote-pagination.ts
@@ -54,10 +54,12 @@ import {
* Generates necessary state, computed and methods for remote pagination of entities in the store.
* When the page changes, it will try to load the current page from cache if it's not present,
* it will call set[collection]Loading(), and you should either create an effect that listens to [collection]Loading
- * and call the api with the [collection]PagedRequest params and use set[Collection]LoadResult to set the result
+ * and call the api with the [collection]PagedRequest params and use set[Collection]Result to set the result
* and changing the status errors manually
* or use withEntitiesLoadingCall to call the api with the [collection]PagedRequest params which handles setting
- * the result and errors automatically. Requires withEntities and withCallStatus to be present before this function.
+ * the result and errors automatically.
+ *
+ * Requires withEntities and withCallStatus to be present before this function.
* @param config
* @param config.pageSize - The number of entities to show per page
* @param config.currentPage - The current page to show
@@ -66,7 +68,9 @@ import {
* @param config.collection - The name of the collection
*
* @example
- * export const ProductsRemoteStore = signalStore(
+ * const entity = type();
+ * const collection = 'products';
+ * export const store = signalStore(
* { providedIn: 'root' },
* // required withEntities and withCallStatus
* withEntities({ entity, collection }),
@@ -96,7 +100,7 @@ import {
* },
* }),
* // withEntitiesLoadingCall is the same as doing the following:
- * // withHooks(({ productsLoading, setProductsError, setProductsLoadResult, ...state }) => ({
+ * // withHooks(({ productsLoading, setProductsError, setProductsResult, ...state }) => ({
* // onInit: async () => {
* // effect(() => {
* // if (isProductsLoading()) {
@@ -110,7 +114,7 @@ import {
* // tap((res) =>
* // patchState(
* // state,
- * // setProductsLoadResult(res.resultList, res.total),
+ * // setProductsResult({ entities: res.resultList, total: res.total } ),
* // ),
* // ),
* // catchError((error) => {
@@ -130,7 +134,7 @@ import {
* store.productsPagedRequest // { startIndex: number, size: number, page: number }
* // generates the following methods
* store.loadProductsPage({ pageIndex: number, forceLoad?: boolean }) // loads the page and sets the requestPage to the pageIndex
- * store.setProductsLoadResult(entities: Product[], total: number) // appends the entities to the cache of entities and total
+ * store.setProductsResult(entities: Product[], total: number) // appends the entities to the cache of entities and total
*/
export function withEntitiesRemotePagination<
Entity extends { id: string | number },
@@ -155,10 +159,12 @@ export function withEntitiesRemotePagination<
* Generates necessary state, computed and methods for remote pagination of entities in the store.
* When the page changes, it will try to load the current page from cache if it's not present,
* it will call set[collection]Loading(), and you should either create an effect that listens to [collection]Loading
- * and call the api with the [collection]PagedRequest params and use set[Collection]LoadResult to set the result
+ * and call the api with the [collection]PagedRequest params and use set[Collection]Result to set the result
* and changing the status errors manually
* or use withEntitiesLoadingCall to call the api with the [collection]PagedRequest params which handles setting
- * the result and errors automatically. Requires withEntities and withCallStatus to be present before this function.
+ * the result and errors automatically.
+ *
+ * Requires withEntities and withCallStatus to be present before this function.
* @param config
* @param config.pageSize - The number of entities to show per page
* @param config.currentPage - The current page to show
@@ -199,7 +205,7 @@ export function withEntitiesRemotePagination<
* },
* }),
* // withEntitiesLoadingCall is the same as doing the following:
- * // withHooks(({ productsLoading, setProductsError, setProductsLoadResult, ...state }) => ({
+ * // withHooks(({ productsLoading, setProductsError, setProductsResult, ...state }) => ({
* // onInit: async () => {
* // effect(() => {
* // if (isProductsLoading()) {
@@ -213,7 +219,7 @@ export function withEntitiesRemotePagination<
* // tap((res) =>
* // patchState(
* // state,
- * // setProductsLoadResult(res.resultList, res.total),
+ * // setProductsResult({ entities: res.resultList, total: res.total } ),
* // ),
* // ),
* // catchError((error) => {
@@ -233,7 +239,7 @@ export function withEntitiesRemotePagination<
* store.productsPagedRequest // { startIndex: number, size: number, page: number }
* // generates the following methods
* store.loadProductsPage({ pageIndex: number, forceLoad?: boolean }) // loads the page and sets the requestPage to the pageIndex
- * store.setProductsLoadResult(entities: Product[], total: number) // appends the entities to the cache of entities and total
+ * store.setProductsResult(entities: Product[], total: number) // appends the entities to the cache of entities and total
*/
export function withEntitiesRemotePagination<
@@ -262,7 +268,7 @@ export function withEntitiesRemotePagination<
* Generates necessary state, computed and methods for remote pagination of entities in the store.
* When the page changes, it will try to load the current page from cache if it's not present,
* it will call set[collection]Loading(), and you should either create an effect that listens to [collection]Loading
- * and call the api with the [collection]PagedRequest params and use set[Collection]LoadResult to set the result
+ * and call the api with the [collection]PagedRequest params and use set[Collection]Result to set the result
* and changing the status errors manually
* or use withEntitiesLoadingCall to call the api with the [collection]PagedRequest params which handles setting
* the result and errors automatically. Requires withEntities and withCallStatus to be used.
@@ -307,7 +313,7 @@ export function withEntitiesRemotePagination<
* },
* }),
* // withEntitiesLoadingCall is the same as doing the following:
- * // withHooks(({ productsLoading, setProductsError, setProductsLoadResult, ...state }) => ({
+ * // withHooks(({ productsLoading, setProductsError, setProductsResult, ...state }) => ({
* // onInit: async () => {
* // effect(() => {
* // if (isProductsLoading()) {
@@ -321,7 +327,7 @@ export function withEntitiesRemotePagination<
* // tap((res) =>
* // patchState(
* // state,
- * // setProductsLoadResult(res.resultList, res.total),
+ * // setProductsResult({ entities: res.resultList, total: res.total } ),
* // ),
* // ),
* // catchError((error) => {
@@ -341,7 +347,7 @@ export function withEntitiesRemotePagination<
* store.productsPagedRequest // { startIndex: number, size: number, page: number }
* // generates the following methods
* store.loadProductsPage({ pageIndex: number, forceLoad?: boolean }) // loads the page and sets the requestPage to the pageIndex
- * store.setProductsLoadResult(entities: Product[], total: number) // appends the entities to the cache of entities and total
+ * store.setProductsResult(entities: Product[], total: number) // appends the entities to the cache of entities and total
*/
export function withEntitiesRemotePagination<
Entity extends { id: string | number },
diff --git a/libs/ngrx-traits/signals/src/lib/with-entities-pagination/with-entities-remote-scroll-pagination.ts b/libs/ngrx-traits/signals/src/lib/with-entities-pagination/with-entities-remote-scroll-pagination.ts
index 8fd40c78..e9050502 100644
--- a/libs/ngrx-traits/signals/src/lib/with-entities-pagination/with-entities-remote-scroll-pagination.ts
+++ b/libs/ngrx-traits/signals/src/lib/with-entities-pagination/with-entities-remote-scroll-pagination.ts
@@ -57,13 +57,19 @@ import {
* of entities keeps growing, ideally for implementing infinite scroll style ui.
* When the page changes, it will try to load the current page from cache if it's not present,
* it will call set[collection]Loading(), and you should either create an effect that listens to is[Collection]Loading
- * and call the api with the [collection]PagedRequest params and use set[Collection]LoadResult to set the result
+ * and call the api with the [collection]PagedRequest params and use set[Collection]Result to set the result
* and changing the status errors manually
* or use withEntitiesLoadingCall to call the api with the [collection]PagedRequest params which handles setting
* the result and errors automatically. Requires withEntities and withCallStatus to be used.
+ *
+ * The generated set[Collection]Result method will append the entities to the cache of entities,
+ * it requires either just set of requested entities set[Collection]Result({ entities }) in which case it will assume there is no more result if you set less entities
+ * than the requested buffer size, or you can provide an extra param to the entities, total set[Collection]Result({ entities, total }) so it calculates if there is more
+ * or a hasMore param set[Collection]Result({entities, hasMore}) that you can set to false to indicate the end of the entities.
+ *
* Requires withEntities and withCallStatus to be present in the store.
* @param config
- * @param config.bufferSize - The number of entities loaded each time
+ * @param config.bufferSize - The number of entities to show per page
* @param config.entity - The entity type
* @param config.collection - The name of the collection
*
@@ -100,7 +106,7 @@ import {
* },
* }),
* // withEntitiesLoadingCall is the same as doing the following:
- * // withHooks(({ productsLoading, setProductsError, setProductsLoadResult, ...state }) => ({
+ * // withHooks(({ productsLoading, setProductsError, setProductsResult, ...state }) => ({
* // onInit: async () => {
* // effect(() => {
* // if (isProductsLoading()) {
@@ -114,7 +120,8 @@ import {
* // tap((res) =>
* // patchState(
* // state,
- * // setProductsLoadResult(res.resultList, res.total),
+ * // // total is not required, you can use hasMore or none see docs
+ * // setProductsResult({ entities: res.resultList, total: res.total } ),
* // ),
* // ),
* // catchError((error) => {
@@ -130,7 +137,7 @@ import {
*
* // in your component add
* store = inject(ProductsRemoteStore);
- * dataSource = getInfiniteScrollDataSource(store, { collecrion: 'products' }) // pass this to your cdkVirtualFor see examples section
+ * dataSource = getInfiniteScrollDataSource(store, { collection: 'products' }) // pass this to your cdkVirtualFor see examples section
* // generates the following signals
* store.productsPagination // { currentPage: number, requestPage: number, bufferSize: 5, total: number, pagesToCache: number, cache: { start: number, end: number } } used internally
* // generates the following computed signals
@@ -140,7 +147,7 @@ import {
* store.loadProductsNextPage() // loads next page
* store.loadProductsPreviousPage() // loads previous page
* store.loadProductsFirstPage() // loads first page
- * store.setProductsLoadResult(entities: Product[], total: number) // appends the entities to the cache of entities and total
+ * store.setProductsResult(entities: Product[], total: number) // appends the entities to the cache of entities and total
*/
export function withEntitiesRemoteScrollPagination<
Entity extends { id: string | number },
@@ -166,10 +173,16 @@ export function withEntitiesRemoteScrollPagination<
* of entities keeps growing, ideally for implementing infinite scroll style ui.
* When the page changes, it will try to load the current page from cache if it's not present,
* it will call set[collection]Loading(), and you should either create an effect that listens to is[Collection]Loading
- * and call the api with the [collection]PagedRequest params and use set[Collection]LoadResult to set the result
+ * and call the api with the [collection]PagedRequest params and use set[Collection]Result to set the result
* and changing the status errors manually
* or use withEntitiesLoadingCall to call the api with the [collection]PagedRequest params which handles setting
* the result and errors automatically. Requires withEntities and withCallStatus to be used.
+ *
+ * The generated set[Collection]Result method will append the entities to the cache of entities,
+ * it requires either just set of requested entities set[Collection]Result({ entities }) in which case it will assume there is no more result if you set less entities
+ * than the requested buffer size, or you can provide an extra param to the entities, total set[Collection]Result({ entities, total }) so it calculates if there is more
+ * or a hasMore param set[Collection]Result({entities, hasMore}) that you can set to false to indicate the end of the entities.
+ *
* Requires withEntities and withCallStatus to be present in the store.
* @param config
* @param config.bufferSize - The number of entities to show per page
@@ -209,7 +222,7 @@ export function withEntitiesRemoteScrollPagination<
* },
* }),
* // withEntitiesLoadingCall is the same as doing the following:
- * // withHooks(({ productsLoading, setProductsError, setProductsLoadResult, ...state }) => ({
+ * // withHooks(({ productsLoading, setProductsError, setProductsResult, ...state }) => ({
* // onInit: async () => {
* // effect(() => {
* // if (isProductsLoading()) {
@@ -223,7 +236,8 @@ export function withEntitiesRemoteScrollPagination<
* // tap((res) =>
* // patchState(
* // state,
- * // setProductsLoadResult(res.resultList, res.total),
+ * // // total is not required, you can use hasMore or none see docs
+ * // setProductsResult({ entities: res.resultList, total: res.total } ),
* // ),
* // ),
* // catchError((error) => {
@@ -239,7 +253,7 @@ export function withEntitiesRemoteScrollPagination<
*
* // in your component add
* store = inject(ProductsRemoteStore);
- * dataSource = getInfiniteScrollDataSource(store, { collecrion: 'products' }) // pass this to your cdkVirtualFor see examples section
+ * dataSource = getInfiniteScrollDataSource(store, { collection: 'products' }) // pass this to your cdkVirtualFor see examples section
* // generates the following signals
* store.productsPagination // { currentPage: number, requestPage: number, bufferSize: 5, total: number, pagesToCache: number, cache: { start: number, end: number } } used internally
* // generates the following computed signals
@@ -249,7 +263,7 @@ export function withEntitiesRemoteScrollPagination<
* store.loadProductsNextPage() // loads next page
* store.loadProductsPreviousPage() // loads previous page
* store.loadProductsFirstPage() // loads first page
- * store.setProductsLoadResult(entities: Product[], total: number) // appends the entities to the cache of entities and total
+ * store.setProductsResult(entities: Product[], total: number) // appends the entities to the cache of entities and total
*/
export function withEntitiesRemoteScrollPagination<
Entity extends { id: string | number },
diff --git a/libs/ngrx-traits/signals/src/lib/with-entities-selection/with-entities-multi-selection.ts b/libs/ngrx-traits/signals/src/lib/with-entities-selection/with-entities-multi-selection.ts
index 8e675bcc..e4371cd6 100644
--- a/libs/ngrx-traits/signals/src/lib/with-entities-selection/with-entities-multi-selection.ts
+++ b/libs/ngrx-traits/signals/src/lib/with-entities-selection/with-entities-multi-selection.ts
@@ -36,7 +36,9 @@ import { getEntitiesMultiSelectionKeys } from './with-entities-multi-selection.u
/**
* Generates state, signals and methods for multi selection of entities.
* Warning: isAll[Collection]Selected and toggleSelectAll[Collection] wont work
- * correctly in using remote pagination, because they cant select all the data
+ * correctly in using remote pagination, because they cant select all the data.
+ *
+ * Requires withEntities to be used before this feature.
* @param config
* @param config.entity - the entity type
* @param config.collection - the collection name
@@ -81,7 +83,9 @@ export function withEntitiesMultiSelection<
/**
* Generates state, signals and methods for multi selection of entities.
* Warning: isAll[Collection]Selected and toggleSelectAll[Collection] wont work
- * correctly in using remote pagination, because they cant select all the data
+ * correctly in using remote pagination, because they cant select all the data.
+ *
+ * Requires withEntities to be used before this feature.
* @param config
* @param config.entity - the entity type
* @param config.collection - the collection name
diff --git a/libs/ngrx-traits/signals/src/lib/with-entities-selection/with-entities-single-selection.ts b/libs/ngrx-traits/signals/src/lib/with-entities-selection/with-entities-single-selection.ts
index 1664deb1..f5ff5fe0 100644
--- a/libs/ngrx-traits/signals/src/lib/with-entities-selection/with-entities-single-selection.ts
+++ b/libs/ngrx-traits/signals/src/lib/with-entities-selection/with-entities-single-selection.ts
@@ -33,7 +33,9 @@ import {
import { getEntitiesSingleSelectionKeys } from './with-entities-single-selection.util';
/**
- * Generates state, computed and methods for single selection of entities. Requires withEntities to be present before this function.
+ * Generates state, computed and methods for single selection of entities.
+ *
+ * Requires withEntities to be present before this function.
* @param config
* @param config.collection - The collection name
* @param config.entity - The entity type
@@ -80,7 +82,9 @@ export function withEntitiesSingleSelection<
}
>;
/**
- * Generates state, computed and methods for single selection of entities. Requires withEntities to be present before this function.
+ * Generates state, computed and methods for single selection of entities.
+ *
+ * Requires withEntities to be present before this function.
* @param config
* @param config.collection - The collection name
* @param config.entity - The entity type
diff --git a/libs/ngrx-traits/signals/src/lib/with-entities-sort/with-entities-local-sort.ts b/libs/ngrx-traits/signals/src/lib/with-entities-sort/with-entities-local-sort.ts
index d85e35ae..7014866c 100644
--- a/libs/ngrx-traits/signals/src/lib/with-entities-sort/with-entities-local-sort.ts
+++ b/libs/ngrx-traits/signals/src/lib/with-entities-sort/with-entities-local-sort.ts
@@ -36,7 +36,9 @@ import {
import { getWithEntitiesSortKeys } from './with-entities-sort.util';
/**
- * Generates necessary state, computed and methods for sorting locally entities in the store. Requires withEntities to be present before this function
+ * Generates necessary state, computed and methods for sorting locally entities in the store.
+ *
+ * Requires withEntities to be present before this function
* @param config
* @param config.defaultSort - The default sort to be applied to the entities
* @param config.entity - The type entity to be used
@@ -77,7 +79,9 @@ export function withEntitiesLocalSort<
}
>;
/**
- * Generates necessary state, computed and methods for sorting locally entities in the store. Requires withEntities to be present before this function
+ * Generates necessary state, computed and methods for sorting locally entities in the store.
+ *
+ * Requires withEntities to be present before this function
* @param config
* @param config.defaultSort - The default sort to be applied to the entities
* @param config.entity - The type entity to be used
diff --git a/libs/ngrx-traits/signals/src/lib/with-entities-sort/with-entities-remote-sort.ts b/libs/ngrx-traits/signals/src/lib/with-entities-sort/with-entities-remote-sort.ts
index 7d0ef684..6fcc400f 100644
--- a/libs/ngrx-traits/signals/src/lib/with-entities-sort/with-entities-remote-sort.ts
+++ b/libs/ngrx-traits/signals/src/lib/with-entities-sort/with-entities-remote-sort.ts
@@ -35,10 +35,12 @@ import { getWithEntitiesSortKeys } from './with-entities-sort.util';
/**
* Generates state, signals, and methods to sort entities remotely. When the sort method is called it will store the sort
* and call set[Collection]Loading, and you should either create an effect that listens to [collection]Loading
- * and call the api with the [collection]Sort params and use wither setAllEntities if is not paginated or set[Collection]LoadResult if is paginated
+ * and call the api with the [collection]Sort params and use wither setAllEntities if is not paginated or set[Collection]Result if is paginated
* with the sorted result that come from the backend, plus changing the status and set errors is needed.
* or use withEntitiesLoadingCall to call the api with the [collection]Sort params which handles setting
- * the result and errors automatically. Requires withEntities and withCallStatus to be present before this function.
+ * the result and errors automatically.
+ *
+ * Requires withEntities and withCallStatus to be present before this function.
*
* @param config
* @param config.defaultSort - The default sort to use when the store is initialized
@@ -125,10 +127,12 @@ export function withEntitiesRemoteSort<
/**
* Generates state, signals, and methods to sort entities remotely. When the sort method is called it will store the sort
* and call set[Collection]Loading, and you should either create an effect that listens to [collection]Loading
- * and call the api with the [collection]Sort params and use wither setAllEntities if is not paginated or set[Collection]LoadResult if is paginated
+ * and call the api with the [collection]Sort params and use wither setAllEntities if is not paginated or set[Collection]Result if is paginated
* with the sorted result that come from the backend, plus changing the status and set errors is needed.
* or use withEntitiesLoadingCall to call the api with the [collection]Sort params which handles setting
- * the result and errors automatically. Requires withEntities and withCallStatus to be present before this function.
+ * the result and errors automatically.
+ *
+ * Requires withEntities and withCallStatus to be present before this function.
*
* @param config
* @param config.defaultSort - The default sort to use when the store is initialized