@mmstack/resource 19.2.0 → 20.0.0
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/README.md +1 -1
- package/fesm2022/mmstack-resource.mjs +10 -10
- package/fesm2022/mmstack-resource.mjs.map +1 -1
- package/index.d.ts +515 -1
- package/package.json +5 -5
- package/lib/mutation-resource.d.ts +0 -92
- package/lib/public_api.d.ts +0 -3
- package/lib/query-resource.d.ts +0 -92
- package/lib/util/cache/cache.d.ts +0 -177
- package/lib/util/cache/cache.interceptor.d.ts +0 -39
- package/lib/util/cache/index.d.ts +0 -2
- package/lib/util/cache/public_api.d.ts +0 -2
- package/lib/util/circuit-breaker.d.ts +0 -74
- package/lib/util/dedupe.interceptor.d.ts +0 -50
- package/lib/util/equality.d.ts +0 -3
- package/lib/util/has-slow-connection.d.ts +0 -1
- package/lib/util/index.d.ts +0 -9
- package/lib/util/persist.d.ts +0 -3
- package/lib/util/public_api.d.ts +0 -3
- package/lib/util/refresh.d.ts +0 -3
- package/lib/util/retry-on-error.d.ts +0 -6
- package/lib/util/url-with-params.d.ts +0 -2
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed, untracked, InjectionToken, inject, isDevMode, signal, effect, linkedSignal,
|
|
1
|
+
import { computed, untracked, InjectionToken, inject, isDevMode, signal, effect, linkedSignal, DestroyRef } from '@angular/core';
|
|
2
2
|
import { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';
|
|
3
3
|
import { of, tap, map, finalize, shareReplay, interval, firstValueFrom, combineLatestWith, filter } from 'rxjs';
|
|
4
4
|
import { HttpContextToken, HttpContext, HttpResponse, HttpParams, httpResource, HttpClient } from '@angular/common/http';
|
|
@@ -755,9 +755,9 @@ function retryOnError(res, opt) {
|
|
|
755
755
|
};
|
|
756
756
|
const ref = effect(() => {
|
|
757
757
|
switch (res.status()) {
|
|
758
|
-
case
|
|
758
|
+
case 'error':
|
|
759
759
|
return onError();
|
|
760
|
-
case
|
|
760
|
+
case 'resolved':
|
|
761
761
|
return onSuccess();
|
|
762
762
|
}
|
|
763
763
|
});
|
|
@@ -881,9 +881,9 @@ function queryResource(request, options) {
|
|
|
881
881
|
// iterate circuit breaker state, is effect as a computed would cause a circular dependency (resource -> cb -> resource)
|
|
882
882
|
const cbEffectRef = effect(() => {
|
|
883
883
|
const status = resource.status();
|
|
884
|
-
if (status ===
|
|
884
|
+
if (status === 'error')
|
|
885
885
|
cb.fail();
|
|
886
|
-
else if (status ===
|
|
886
|
+
else if (status === 'resolved')
|
|
887
887
|
cb.success();
|
|
888
888
|
});
|
|
889
889
|
const set = (value) => {
|
|
@@ -1007,22 +1007,22 @@ function mutationResource(request, options = {}) {
|
|
|
1007
1007
|
const value$ = toObservable(resource.value);
|
|
1008
1008
|
const statusSub = toObservable(resource.status)
|
|
1009
1009
|
.pipe(combineLatestWith(error$, value$), map(([status, error, value]) => {
|
|
1010
|
-
if (status ===
|
|
1010
|
+
if (status === 'error' && error) {
|
|
1011
1011
|
return {
|
|
1012
|
-
status:
|
|
1012
|
+
status: 'error',
|
|
1013
1013
|
error,
|
|
1014
1014
|
};
|
|
1015
1015
|
}
|
|
1016
|
-
if (status ===
|
|
1016
|
+
if (status === 'resolved' && value !== null) {
|
|
1017
1017
|
return {
|
|
1018
|
-
status:
|
|
1018
|
+
status: 'resolved',
|
|
1019
1019
|
value,
|
|
1020
1020
|
};
|
|
1021
1021
|
}
|
|
1022
1022
|
return null;
|
|
1023
1023
|
}), filter((v) => v !== null), takeUntilDestroyed(destroyRef))
|
|
1024
1024
|
.subscribe((result) => {
|
|
1025
|
-
if (result.status ===
|
|
1025
|
+
if (result.status === 'error')
|
|
1026
1026
|
onError?.(result.error, ctx);
|
|
1027
1027
|
else
|
|
1028
1028
|
onSuccess?.(result.value, ctx);
|