diff --git a/libs/ngrx-traits/signals/api-docs.md b/libs/ngrx-traits/signals/api-docs.md index 44f1339..3a6de6c 100644 --- a/libs/ngrx-traits/signals/api-docs.md +++ b/libs/ngrx-traits/signals/api-docs.md @@ -17,7 +17,11 @@ call and store the result of the call. The generated methods are rxMethods with the same name as the original call, which accepts either the original parameters or a Signal or Observable of the same type as the original parameters. The original call can only have zero or one parameter, use an object with multiple -props as first param if you need more.
+props as first param if you need more. +If the name start with an underscore, the call will be private and all generated methods +will also start with an underscore, making it only accessible inside the store. +Call configuration object for withCalls
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 @@ -172,7 +176,9 @@ call and store the result of the call. The generated methods are rxMethods with the same name as the original call, which accepts either the original parameters or a Signal or Observable of the same type as the original parameters. The original call can only have zero or one parameter, use an object with multiple -props as first param if you need more.
+props as first param if you need more. +If the name start with an underscore, the call will be private and all generated methods +will also start with an underscore, making it only accessible inside the store. **Kind**: global function **Warning**: The default mapPipe is [exhaustMap](https://www.learnrxjs.io/learn-rxjs/operators/transformation/exhaustmap). If your call returns an observable that does not complete after the first value is emitted, any changes to the input params will be ignored. Either specify [switchMap](https://www.learnrxjs.io/learn-rxjs/operators/transformation/switchmap) as mapPipe, or use [take(1)](https://www.learnrxjs.io/learn-rxjs/operators/filtering/take) or [first()](https://www.learnrxjs.io/learn-rxjs/operators/filtering/first) as part of your call. @@ -199,6 +205,10 @@ withCalls(({ productsSelectedEntity }) => ({ onError: (error, callParam) => { // do something with the error }, + skipWhen: (callParam) => { + // if return true, the call will be skip, if false, the call will execute as usual + return // boolean | PromiseCall configuration object for withCalls
+ +**Kind**: global function + +| Param | Description | +| --- | --- | +| config |the call configuration
| +| config.call |required, the function that will be called
| +| config.mapPipe |optional, default exhaustMap the pipe operator that will be used to map the call result
| +| config.storeResult |optional, default true, if false, the result will not be stored in the store
| +| config.resultProp |optional, default callName + 'Result', the name of the prop where the result will be stored
| +| config.onSuccess |optional, a function that will be called when the call is successful
| +| config.mapError |optional, a function that will be called to transform the error before storing it
| +| config.onError |optional, a function that will be called when the call fails
| +| config.skipWhen |optional, a function that will be called to determine if the call should be skipped
| + ## withEntitiesLocalFilter(configFactory) diff --git a/libs/ngrx-traits/signals/src/lib/with-logger/with-state-logger.ts b/libs/ngrx-traits/signals/src/lib/with-logger/with-state-logger.ts index 98b854f..fe5c425 100644 --- a/libs/ngrx-traits/signals/src/lib/with-logger/with-state-logger.ts +++ b/libs/ngrx-traits/signals/src/lib/with-logger/with-state-logger.ts @@ -1,6 +1,8 @@ import { effect } from '@angular/core'; import { + EmptyFeatureResult, getState, + SignalStoreFeature, signalStoreFeature, SignalStoreFeatureResult, type, @@ -18,7 +20,7 @@ export function withStateLogger({ }: { name: string; filterState?: (state: Input['state']) => Partial; -}) { +}): SignalStoreFeature { return signalStoreFeature( type(), withHooks({ diff --git a/libs/ngrx-traits/signals/src/lib/with-sync-to-route-query-params/with-sync-to-route-query-params.ts b/libs/ngrx-traits/signals/src/lib/with-sync-to-route-query-params/with-sync-to-route-query-params.ts index b032284..e8758bc 100644 --- a/libs/ngrx-traits/signals/src/lib/with-sync-to-route-query-params/with-sync-to-route-query-params.ts +++ b/libs/ngrx-traits/signals/src/lib/with-sync-to-route-query-params/with-sync-to-route-query-params.ts @@ -2,7 +2,9 @@ import { computed, inject } from '@angular/core'; import { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop'; import { ActivatedRoute, Router } from '@angular/router'; import { + EmptyFeatureResult, Prettify, + SignalStoreFeature, signalStoreFeature, SignalStoreFeatureResult, StateSignals, @@ -58,7 +60,10 @@ export function withSyncToRouteQueryParams< Input extends SignalStoreFeatureResult, Params extends Record