@belte/belte 0.19.2 → 0.19.3
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/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/lib/shared/cache.ts +9 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @belte/belte
|
|
2
2
|
|
|
3
|
+
## 0.19.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`ae17e17`](https://github.com/briancray/belte/commit/ae17e17cac4a52a7506e411a572857cdf6f2d5d1) - type the warm sync return as Promise<Return> | Return ([`a00afa7`](https://github.com/briancray/belte/commit/a00afa7955fef3755f91b8a4da935916701c070a))
|
|
8
|
+
|
|
3
9
|
## 0.19.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/package.json
CHANGED
package/src/lib/shared/cache.ts
CHANGED
|
@@ -72,7 +72,7 @@ the child.
|
|
|
72
72
|
export function cache<Args, Return>(
|
|
73
73
|
fn: RemoteFunction<Args, Return>,
|
|
74
74
|
options?: CacheOptions,
|
|
75
|
-
): (args?: Args) => Promise<Return>
|
|
75
|
+
): (args?: Args) => Promise<Return> | Return
|
|
76
76
|
export function cache<Args>(
|
|
77
77
|
fn: RawRemoteFunction<Args>,
|
|
78
78
|
options?: CacheOptions,
|
|
@@ -118,13 +118,14 @@ export function cache<Args, Return>(
|
|
|
118
118
|
invalidate the replacement entry carries no value and falls through
|
|
119
119
|
to the async fetch as before.
|
|
120
120
|
|
|
121
|
-
The
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
never `.
|
|
121
|
+
The decoded overload is typed `Promise<Return> | Return` so the warm
|
|
122
|
+
sync return is honest at the type level: a non-thenable is the only
|
|
123
|
+
thing {#await} can render synchronously, and surfacing the union turns
|
|
124
|
+
chaining `.then`/`.catch`/`.finally` on a read into a compile error
|
|
125
|
+
rather than a runtime throw on warm hits. Consume cache via
|
|
126
|
+
`await`/`{#await}` (both accept the union); in the await form handle
|
|
127
|
+
errors with `try/catch`, never `.catch`. Raw and producer callers stay
|
|
128
|
+
`Promise<…>` — they never take this sync path.
|
|
128
129
|
|
|
129
130
|
Each warm read returns its own clone of the stored value: the entry's
|
|
130
131
|
value is decoded once at hydration and would otherwise be handed by
|