@one-paragon/angular-utilities 2.0.23 → 2.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/one-paragon-angular-utilities.mjs +43 -5
- package/fesm2022/one-paragon-angular-utilities.mjs.map +1 -1
- package/http-request-state/RequestStateStore.d.ts +29 -1
- package/package.json +1 -1
- package/table-builder/classes/TableState.d.ts +1 -0
- package/table-builder/directives/table-wrapper.directive.d.ts +1 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Observable, Subscription } from 'rxjs';
|
|
2
2
|
import { RequestFactory as RequestFactory, RequestStatus, RequestState, RequestStateOptions } from './types';
|
|
3
3
|
import { HttpErrorResponse } from '@angular/common/http';
|
|
4
|
-
import { Signal } from '@angular/core';
|
|
4
|
+
import { InjectionToken, Signal } from '@angular/core';
|
|
5
5
|
export interface RequestResponse<TParam extends any[], T> {
|
|
6
6
|
requestParams: [...TParam];
|
|
7
7
|
response: RequestState<T>;
|
|
8
8
|
}
|
|
9
9
|
export declare class RequestStateStore<TParam extends any[], V, R = null, T = R extends null ? V : R> {
|
|
10
|
+
#private;
|
|
10
11
|
private _state;
|
|
11
12
|
private setState;
|
|
12
13
|
state: Signal<RequestResponse<TParam, T>>;
|
|
@@ -16,6 +17,9 @@ export declare class RequestStateStore<TParam extends any[], V, R = null, T = R
|
|
|
16
17
|
private req;
|
|
17
18
|
private injector;
|
|
18
19
|
private destroy$;
|
|
20
|
+
private defaultErrorHandling?;
|
|
21
|
+
private _useDefaultErrorHandler?;
|
|
22
|
+
private defaultSuccessHandling?;
|
|
19
23
|
constructor(req: RequestFactory<TParam, V>, options?: RequestStateOptions<TParam>, project?: (v: V) => R);
|
|
20
24
|
reset(): void;
|
|
21
25
|
private flatteningStrategy;
|
|
@@ -42,6 +46,14 @@ export declare class RequestStateStore<TParam extends any[], V, R = null, T = R
|
|
|
42
46
|
private selectSuccessOrError$;
|
|
43
47
|
errorHandled: boolean;
|
|
44
48
|
onError(cb: (error: HttpErrorResponse) => void): this;
|
|
49
|
+
/**
|
|
50
|
+
* if no handler was provided will call `console.error`
|
|
51
|
+
*/
|
|
52
|
+
useDefaultErrorHandler(): this;
|
|
53
|
+
/**
|
|
54
|
+
* if no handler was provided will call `console.log` with 'Success'
|
|
55
|
+
*/
|
|
56
|
+
useDefaultSuccessHandler(): this;
|
|
45
57
|
onSuccess(cb: (body?: T) => void): this;
|
|
46
58
|
onSuccessOrError(cb: () => void): this;
|
|
47
59
|
onSuccessWithRequest(func: (state: {
|
|
@@ -67,3 +79,19 @@ export declare class CancellationToken {
|
|
|
67
79
|
}
|
|
68
80
|
export declare function wrapInArr<T>(sig: Signal<T>): Signal<[T]>;
|
|
69
81
|
export declare function wrapInArr<T>(obs: Observable<T>): Observable<[T]>;
|
|
82
|
+
export interface RequestStateStoreConfig {
|
|
83
|
+
/**
|
|
84
|
+
* if `useDefaultErrorHandler` is `true` this will run on each error if no other handler provided.
|
|
85
|
+
* else can be used by call `.useDefaultHandler`
|
|
86
|
+
*/
|
|
87
|
+
defaultErrorHandling?: (e?: any) => void;
|
|
88
|
+
/**
|
|
89
|
+
* if `useDefaultErrorHandler` is `true` `defaultErrorHandling` will run on each error if no other handler provided.
|
|
90
|
+
*/
|
|
91
|
+
useDefaultErrorHandler?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* will be called if `useDefaultSuccess` is used
|
|
94
|
+
*/
|
|
95
|
+
defaultSuccessHandling?: <T>(e?: T) => void;
|
|
96
|
+
}
|
|
97
|
+
export declare const RequestStateStoreConfigToken: InjectionToken<RequestStateStoreConfig>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TableCustomFilterDirective, TableFilterDirective } from "./tb-filter.directive";
|
|
2
2
|
import * as i0 from "@angular/core";
|
|
3
3
|
export declare class TableWrapperDirective {
|
|
4
|
-
$registrations: import("@angular/core").WritableSignal<(
|
|
4
|
+
$registrations: import("@angular/core").WritableSignal<(TableCustomFilterDirective | TableFilterDirective)[]>;
|
|
5
5
|
register(filter: TableCustomFilterDirective | TableFilterDirective): void;
|
|
6
6
|
static ɵfac: i0.ɵɵFactoryDeclaration<TableWrapperDirective, never>;
|
|
7
7
|
static ɵdir: i0.ɵɵDirectiveDeclaration<TableWrapperDirective, "[tbWrapper]", never, {}, {}, never, never, true, never>;
|