@vc-shell/framework 2.5.0-pr338.cf3c39c → 2.5.0-pr339.3f40f2e
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.
|
@@ -6,6 +6,25 @@ export interface LatestRequest {
|
|
|
6
6
|
complete(): void;
|
|
7
7
|
}
|
|
8
8
|
export interface UseLatestRequestReturn {
|
|
9
|
+
/**
|
|
10
|
+
* Runs a request and hands back its result only while it is still the newest.
|
|
11
|
+
* A superseded request resolves to `undefined`, so the caller returns early
|
|
12
|
+
* instead of writing a stale answer:
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* const result = await search.latest(client.searchProducts(criteria));
|
|
16
|
+
* if (!result) return;
|
|
17
|
+
* searchResult.value = result;
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* This is `begin`/`isCurrent`/`complete` with the bookkeeping folded in —
|
|
21
|
+
* there is no `finally` to forget. Reach for `begin` directly only when the
|
|
22
|
+
* request and the check cannot sit in the same function.
|
|
23
|
+
*
|
|
24
|
+
* Rejections propagate untouched. `undefined` means superseded, so a request
|
|
25
|
+
* whose own successful result is `undefined` needs `begin` instead.
|
|
26
|
+
*/
|
|
27
|
+
latest<T>(request: Promise<T>): Promise<T | undefined>;
|
|
9
28
|
/** Starts a request and supersedes any earlier one. */
|
|
10
29
|
begin(): LatestRequest;
|
|
11
30
|
/** Supersedes the in-flight request without starting a new one — e.g. on selection change. */
|
|
@@ -23,17 +42,15 @@ export interface UseLatestRequestReturn {
|
|
|
23
42
|
* const search = useLatestRequest();
|
|
24
43
|
*
|
|
25
44
|
* async function load(criteria) {
|
|
26
|
-
* const
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* if (!request.isCurrent()) return; // a newer search won
|
|
30
|
-
* items.value = result;
|
|
31
|
-
* } finally {
|
|
32
|
-
* request.complete();
|
|
33
|
-
* }
|
|
45
|
+
* const result = await search.latest(api.search(criteria));
|
|
46
|
+
* if (!result) return; // a newer search won
|
|
47
|
+
* items.value = result;
|
|
34
48
|
* }
|
|
35
49
|
* ```
|
|
36
50
|
*
|
|
51
|
+
* `begin` is the same thing with the bookkeeping exposed, for the cases where
|
|
52
|
+
* the request and the check cannot sit in the same function.
|
|
53
|
+
*
|
|
37
54
|
* This discards the late result rather than cancelling the request: the
|
|
38
55
|
* generated API clients build their own `RequestInit` and take no `AbortSignal`,
|
|
39
56
|
* so there is nothing to cancel through. Aborting would additionally save the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../core/composables/useLatestRequest/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkD,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AAE/E,MAAM,WAAW,aAAa;IAC5B,2FAA2F;IAC3F,SAAS,IAAI,OAAO,CAAC;IACrB,0FAA0F;IAC1F,QAAQ,IAAI,IAAI,CAAC;CAClB;AAED,MAAM,WAAW,sBAAsB;IACrC,uDAAuD;IACvD,KAAK,IAAI,aAAa,CAAC;IACvB,8FAA8F;IAC9F,UAAU,IAAI,IAAI,CAAC;IACnB,2FAA2F;IAC3F,OAAO,IAAI,IAAI,CAAC;IAChB,sDAAsD;IACtD,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;CACjC;AAED
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../core/composables/useLatestRequest/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkD,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AAE/E,MAAM,WAAW,aAAa;IAC5B,2FAA2F;IAC3F,SAAS,IAAI,OAAO,CAAC;IACrB,0FAA0F;IAC1F,QAAQ,IAAI,IAAI,CAAC;CAClB;AAED,MAAM,WAAW,sBAAsB;IACrC;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IACvD,uDAAuD;IACvD,KAAK,IAAI,aAAa,CAAC;IACvB,8FAA8F;IAC9F,UAAU,IAAI,IAAI,CAAC;IACnB,2FAA2F;IAC3F,OAAO,IAAI,IAAI,CAAC;IAChB,sDAAsD;IACtD,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,IAAI,sBAAsB,CAsDzD"}
|
package/dist/framework.js
CHANGED
|
@@ -752,25 +752,35 @@ function Il() {
|
|
|
752
752
|
const e = b(!1);
|
|
753
753
|
let t = 0, a = !1;
|
|
754
754
|
function n() {
|
|
755
|
-
const
|
|
756
|
-
let
|
|
755
|
+
const l = ++t;
|
|
756
|
+
let c = !1;
|
|
757
757
|
return a || (e.value = !0), {
|
|
758
|
-
isCurrent: () => !a &&
|
|
758
|
+
isCurrent: () => !a && l === t,
|
|
759
759
|
complete: () => {
|
|
760
|
-
|
|
760
|
+
c || (c = !0, !a && l === t && (e.value = !1));
|
|
761
761
|
}
|
|
762
762
|
};
|
|
763
763
|
}
|
|
764
|
-
function s() {
|
|
765
|
-
|
|
764
|
+
async function s(l) {
|
|
765
|
+
const c = n();
|
|
766
|
+
try {
|
|
767
|
+
const u = await l;
|
|
768
|
+
return c.isCurrent() ? u : void 0;
|
|
769
|
+
} finally {
|
|
770
|
+
c.complete();
|
|
771
|
+
}
|
|
766
772
|
}
|
|
767
773
|
function o() {
|
|
768
|
-
|
|
774
|
+
t++, e.value = !1;
|
|
775
|
+
}
|
|
776
|
+
function r() {
|
|
777
|
+
a = !0, o();
|
|
769
778
|
}
|
|
770
|
-
return rt() && it(
|
|
779
|
+
return rt() && it(r), {
|
|
780
|
+
latest: s,
|
|
771
781
|
begin: n,
|
|
772
|
-
invalidate:
|
|
773
|
-
dispose:
|
|
782
|
+
invalidate: o,
|
|
783
|
+
dispose: r,
|
|
774
784
|
pending: Me(e)
|
|
775
785
|
};
|
|
776
786
|
}
|
|
@@ -2121,12 +2131,12 @@ function xo() {
|
|
|
2121
2131
|
hasNotification: (t) => e.hasNotification(t)
|
|
2122
2132
|
});
|
|
2123
2133
|
}
|
|
2124
|
-
const $o = "2.5.0-
|
|
2134
|
+
const $o = "2.5.0-pr339.3f40f2e";
|
|
2125
2135
|
function Ko() {
|
|
2126
2136
|
return {
|
|
2127
2137
|
version: $o,
|
|
2128
|
-
buildDate: "2026-
|
|
2129
|
-
gitHash: "
|
|
2138
|
+
buildDate: "2026-09-01T06:36:03.116Z",
|
|
2139
|
+
gitHash: "3f40f2eb0"
|
|
2130
2140
|
};
|
|
2131
2141
|
}
|
|
2132
2142
|
function zo(e = Ko()) {
|