@one-paragon/angular-utilities 2.4.5-beta.2 → 2.4.5
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.
|
@@ -576,13 +576,12 @@ class RequestStateStore {
|
|
|
576
576
|
else
|
|
577
577
|
console.error(e);
|
|
578
578
|
};
|
|
579
|
-
this.subscriber = (srcObservable, func) => {
|
|
580
|
-
return srcObservable.pipe(tap(func), takeUntil(this.destroy$)).subscribe();
|
|
581
|
-
};
|
|
582
579
|
/**
|
|
583
580
|
* @deprecated use the standalone subscriber helper function
|
|
584
581
|
*/
|
|
585
|
-
this.on =
|
|
582
|
+
this.on = (srcObservable, func) => {
|
|
583
|
+
return srcObservable.pipe(tap(func), takeUntil(this.destroy$)).subscribe();
|
|
584
|
+
};
|
|
586
585
|
/**
|
|
587
586
|
* @param params An observable or signal that returns an array to be spread into the request function.
|
|
588
587
|
* If undefined is returned, the request will not be made.
|
|
@@ -623,7 +622,6 @@ class RequestStateStore {
|
|
|
623
622
|
this.state$ = toObservable(this.state);
|
|
624
623
|
this.selectRequestState$ = this.state$.pipe(map(s => s.response));
|
|
625
624
|
this.selectResponse$ = this.selectRequestState$.pipe(filter(isSuccessState), map(state => state.body));
|
|
626
|
-
this.selectSuccessOrError$ = this.state$.pipe(map(r => r.response), filter(isSuccessOrErrorState), map(() => undefined));
|
|
627
625
|
/**
|
|
628
626
|
* @deprecated use selectRequestState$ instead
|
|
629
627
|
*/
|
|
@@ -663,7 +661,12 @@ class RequestStateStore {
|
|
|
663
661
|
}
|
|
664
662
|
onErrorResponse(cb) {
|
|
665
663
|
this.errorHandled = true;
|
|
666
|
-
this.effectOnState('error', cb);
|
|
664
|
+
this.effectOnState('error', (e, p) => cb(e, ...p));
|
|
665
|
+
return this;
|
|
666
|
+
}
|
|
667
|
+
onErrorRequest(cb) {
|
|
668
|
+
this.errorHandled = true;
|
|
669
|
+
this.effectOnState('error', (_, p) => cb(...p));
|
|
667
670
|
return this;
|
|
668
671
|
}
|
|
669
672
|
onErrorWithRequest(func) {
|
|
@@ -691,13 +694,17 @@ class RequestStateStore {
|
|
|
691
694
|
return this;
|
|
692
695
|
}
|
|
693
696
|
onSuccessResponse(cb) {
|
|
694
|
-
this.effectOnState('success', cb);
|
|
697
|
+
this.effectOnState('success', (response, requestParams) => cb(response, ...requestParams));
|
|
695
698
|
return this;
|
|
696
699
|
}
|
|
697
700
|
onSuccessWithRequest(func) {
|
|
698
701
|
this.effectOnState('success', (body, requestParams) => func({ requestParams, body }));
|
|
699
702
|
return this;
|
|
700
703
|
}
|
|
704
|
+
onSuccessRequest(cb) {
|
|
705
|
+
this.effectOnState('success', (_, requestParams) => cb(...requestParams));
|
|
706
|
+
return this;
|
|
707
|
+
}
|
|
701
708
|
onSuccessOrError(cb) {
|
|
702
709
|
this.effectOnState('both', cb);
|
|
703
710
|
return this;
|