@pyreon/query 0.11.4 → 0.11.6
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 +58 -56
- package/lib/index.js.map +1 -1
- package/lib/types/index.d.ts +7 -7
- package/package.json +16 -16
- package/src/index.ts +21 -33
- package/src/query-client.ts +5 -5
- package/src/tests/query-additional.test.tsx +59 -59
- package/src/tests/query.test.tsx +243 -243
- package/src/tests/sse.test.tsx +131 -131
- package/src/tests/subscription.test.tsx +97 -97
- package/src/use-infinite-query.ts +7 -7
- package/src/use-is-fetching.ts +5 -5
- package/src/use-mutation.ts +8 -8
- package/src/use-queries.ts +6 -6
- package/src/use-query-error-reset-boundary.ts +6 -6
- package/src/use-query.ts +8 -8
- package/src/use-sse.ts +19 -19
- package/src/use-subscription.ts +18 -18
- package/src/use-suspense-query.ts +12 -12
package/src/use-mutation.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { onUnmount } from
|
|
2
|
-
import type { Signal } from
|
|
3
|
-
import { batch, signal } from
|
|
1
|
+
import { onUnmount } from '@pyreon/core'
|
|
2
|
+
import type { Signal } from '@pyreon/reactivity'
|
|
3
|
+
import { batch, signal } from '@pyreon/reactivity'
|
|
4
4
|
import type {
|
|
5
5
|
DefaultError,
|
|
6
6
|
MutateFunction,
|
|
7
7
|
MutationObserverOptions,
|
|
8
8
|
MutationObserverResult,
|
|
9
|
-
} from
|
|
10
|
-
import { MutationObserver } from
|
|
11
|
-
import { useQueryClient } from
|
|
9
|
+
} from '@tanstack/query-core'
|
|
10
|
+
import { MutationObserver } from '@tanstack/query-core'
|
|
11
|
+
import { useQueryClient } from './query-client'
|
|
12
12
|
|
|
13
13
|
export interface UseMutationResult<
|
|
14
14
|
TData,
|
|
@@ -20,7 +20,7 @@ export interface UseMutationResult<
|
|
|
20
20
|
result: Signal<MutationObserverResult<TData, TError, TVariables, TContext>>
|
|
21
21
|
data: Signal<TData | undefined>
|
|
22
22
|
error: Signal<TError | null>
|
|
23
|
-
status: Signal<
|
|
23
|
+
status: Signal<'idle' | 'pending' | 'success' | 'error'>
|
|
24
24
|
isPending: Signal<boolean>
|
|
25
25
|
isSuccess: Signal<boolean>
|
|
26
26
|
isError: Signal<boolean>
|
|
@@ -65,7 +65,7 @@ export function useMutation<
|
|
|
65
65
|
const resultSig = signal<MutationObserverResult<TData, TError, TVariables, TContext>>(initial)
|
|
66
66
|
const dataSig = signal<TData | undefined>(initial.data)
|
|
67
67
|
const errorSig = signal<TError | null>(initial.error ?? null)
|
|
68
|
-
const statusSig = signal<
|
|
68
|
+
const statusSig = signal<'idle' | 'pending' | 'success' | 'error'>(initial.status)
|
|
69
69
|
const isPending = signal(initial.isPending)
|
|
70
70
|
const isSuccess = signal(initial.isSuccess)
|
|
71
71
|
const isError = signal(initial.isError)
|
package/src/use-queries.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { onUnmount } from
|
|
2
|
-
import type { Signal } from
|
|
3
|
-
import { effect, signal } from
|
|
1
|
+
import { onUnmount } from '@pyreon/core'
|
|
2
|
+
import type { Signal } from '@pyreon/reactivity'
|
|
3
|
+
import { effect, signal } from '@pyreon/reactivity'
|
|
4
4
|
import type {
|
|
5
5
|
DefaultError,
|
|
6
6
|
QueryKey,
|
|
7
7
|
QueryObserverOptions,
|
|
8
8
|
QueryObserverResult,
|
|
9
|
-
} from
|
|
10
|
-
import { QueriesObserver } from
|
|
11
|
-
import { useQueryClient } from
|
|
9
|
+
} from '@tanstack/query-core'
|
|
10
|
+
import { QueriesObserver } from '@tanstack/query-core'
|
|
11
|
+
import { useQueryClient } from './query-client'
|
|
12
12
|
|
|
13
13
|
export type UseQueriesOptions<TQueryKey extends QueryKey = QueryKey> = QueryObserverOptions<
|
|
14
14
|
unknown,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Props, VNode, VNodeChild } from
|
|
2
|
-
import { createContext, provide, useContext } from
|
|
3
|
-
import { useQueryClient } from
|
|
1
|
+
import type { Props, VNode, VNodeChild } from '@pyreon/core'
|
|
2
|
+
import { createContext, provide, useContext } from '@pyreon/core'
|
|
3
|
+
import { useQueryClient } from './query-client'
|
|
4
4
|
|
|
5
5
|
// ─── Context ────────────────────────────────────────────────────────────────
|
|
6
6
|
|
|
@@ -42,7 +42,7 @@ export function QueryErrorResetBoundary(props: QueryErrorResetBoundaryProps): VN
|
|
|
42
42
|
reset: () => {
|
|
43
43
|
// Reset all active queries that are in error state so they refetch.
|
|
44
44
|
client.refetchQueries({
|
|
45
|
-
predicate: (query) => query.state.status ===
|
|
45
|
+
predicate: (query) => query.state.status === 'error',
|
|
46
46
|
})
|
|
47
47
|
},
|
|
48
48
|
}
|
|
@@ -50,7 +50,7 @@ export function QueryErrorResetBoundary(props: QueryErrorResetBoundaryProps): VN
|
|
|
50
50
|
provide(QueryErrorResetBoundaryContext, value)
|
|
51
51
|
|
|
52
52
|
const ch = props.children
|
|
53
|
-
return (typeof ch ===
|
|
53
|
+
return (typeof ch === 'function' ? (ch as () => VNodeChild)() : ch) as VNode
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// ─── useQueryErrorResetBoundary ──────────────────────────────────────────────
|
|
@@ -76,7 +76,7 @@ export function useQueryErrorResetBoundary(): ErrorResetBoundaryValue {
|
|
|
76
76
|
return {
|
|
77
77
|
reset: () => {
|
|
78
78
|
client.refetchQueries({
|
|
79
|
-
predicate: (query) => query.state.status ===
|
|
79
|
+
predicate: (query) => query.state.status === 'error',
|
|
80
80
|
})
|
|
81
81
|
},
|
|
82
82
|
}
|
package/src/use-query.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { onUnmount } from
|
|
2
|
-
import type { Signal } from
|
|
3
|
-
import { batch, effect, signal } from
|
|
1
|
+
import { onUnmount } from '@pyreon/core'
|
|
2
|
+
import type { Signal } from '@pyreon/reactivity'
|
|
3
|
+
import { batch, effect, signal } from '@pyreon/reactivity'
|
|
4
4
|
import type {
|
|
5
5
|
DefaultError,
|
|
6
6
|
QueryKey,
|
|
7
7
|
QueryObserverOptions,
|
|
8
8
|
QueryObserverResult,
|
|
9
|
-
} from
|
|
10
|
-
import { QueryObserver } from
|
|
11
|
-
import { useQueryClient } from
|
|
9
|
+
} from '@tanstack/query-core'
|
|
10
|
+
import { QueryObserver } from '@tanstack/query-core'
|
|
11
|
+
import { useQueryClient } from './query-client'
|
|
12
12
|
|
|
13
13
|
export interface UseQueryResult<TData, TError = DefaultError> {
|
|
14
14
|
/** Raw signal — the full observer result. Fine-grained accessors below are preferred. */
|
|
15
15
|
result: Signal<QueryObserverResult<TData, TError>>
|
|
16
16
|
data: Signal<TData | undefined>
|
|
17
17
|
error: Signal<TError | null>
|
|
18
|
-
status: Signal<
|
|
18
|
+
status: Signal<'pending' | 'error' | 'success'>
|
|
19
19
|
isPending: Signal<boolean>
|
|
20
20
|
isLoading: Signal<boolean>
|
|
21
21
|
isFetching: Signal<boolean>
|
|
@@ -52,7 +52,7 @@ export function useQuery<TData = unknown, TError = DefaultError, TKey extends Qu
|
|
|
52
52
|
const resultSig = signal<QueryObserverResult<TData, TError>>(initial)
|
|
53
53
|
const dataSig = signal<TData | undefined>(initial.data)
|
|
54
54
|
const errorSig = signal<TError | null>(initial.error ?? null)
|
|
55
|
-
const statusSig = signal<
|
|
55
|
+
const statusSig = signal<'pending' | 'error' | 'success'>(initial.status)
|
|
56
56
|
const isPending = signal(initial.isPending)
|
|
57
57
|
const isLoading = signal(initial.isLoading)
|
|
58
58
|
const isFetching = signal(initial.isFetching)
|
package/src/use-sse.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { onUnmount } from
|
|
2
|
-
import type { Signal } from
|
|
3
|
-
import { batch, effect, signal } from
|
|
4
|
-
import type { QueryClient } from
|
|
5
|
-
import { useQueryClient } from
|
|
1
|
+
import { onUnmount } from '@pyreon/core'
|
|
2
|
+
import type { Signal } from '@pyreon/reactivity'
|
|
3
|
+
import { batch, effect, signal } from '@pyreon/reactivity'
|
|
4
|
+
import type { QueryClient } from '@tanstack/query-core'
|
|
5
|
+
import { useQueryClient } from './query-client'
|
|
6
6
|
|
|
7
7
|
// ─── Types ───────────────────────────────────────────────────────────────────
|
|
8
8
|
|
|
9
|
-
export type SSEStatus =
|
|
9
|
+
export type SSEStatus = 'connecting' | 'connected' | 'disconnected' | 'error'
|
|
10
10
|
|
|
11
11
|
export interface UseSSEOptions<T = string> {
|
|
12
12
|
/** EventSource URL — can be a signal for reactive URLs */
|
|
@@ -78,9 +78,9 @@ export interface UseSSEResult<T> {
|
|
|
78
78
|
export function useSSE<T = string>(options: UseSSEOptions<T>): UseSSEResult<T> {
|
|
79
79
|
const queryClient = useQueryClient()
|
|
80
80
|
const data = signal<T | null>(null)
|
|
81
|
-
const status = signal<SSEStatus>(
|
|
81
|
+
const status = signal<SSEStatus>('disconnected')
|
|
82
82
|
const error = signal<Event | null>(null)
|
|
83
|
-
const lastEventId = signal(
|
|
83
|
+
const lastEventId = signal('')
|
|
84
84
|
const readyState = signal<number>(2) // Start as CLOSED until connected
|
|
85
85
|
|
|
86
86
|
let es: EventSource | null = null
|
|
@@ -98,18 +98,18 @@ export function useSSE<T = string>(options: UseSSEOptions<T>): UseSSEResult<T> {
|
|
|
98
98
|
: null
|
|
99
99
|
|
|
100
100
|
function getUrl(): string {
|
|
101
|
-
return typeof options.url ===
|
|
101
|
+
return typeof options.url === 'function' ? options.url() : options.url
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
function isEnabled(): boolean {
|
|
105
105
|
if (options.enabled === undefined) return true
|
|
106
|
-
return typeof options.enabled ===
|
|
106
|
+
return typeof options.enabled === 'function' ? options.enabled() : options.enabled
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
function handleMessage(event: MessageEvent): void {
|
|
110
110
|
try {
|
|
111
111
|
// Track lastEventId from the SSE spec
|
|
112
|
-
if (event.lastEventId !== undefined && event.lastEventId !==
|
|
112
|
+
if (event.lastEventId !== undefined && event.lastEventId !== '') {
|
|
113
113
|
lastEventId.set(event.lastEventId)
|
|
114
114
|
}
|
|
115
115
|
const parsed = options.parse ? options.parse(event.data as string) : (event.data as T)
|
|
@@ -146,7 +146,7 @@ export function useSSE<T = string>(options: UseSSEOptions<T>): UseSSEResult<T> {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
function handleError(event: Event): void {
|
|
149
|
-
status.set(
|
|
149
|
+
status.set('error')
|
|
150
150
|
error.set(event)
|
|
151
151
|
readyState.set(es?.readyState ?? EventSource.CLOSED)
|
|
152
152
|
options.onError?.(event)
|
|
@@ -172,11 +172,11 @@ export function useSSE<T = string>(options: UseSSEOptions<T>): UseSSEResult<T> {
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
if (!isEnabled()) {
|
|
175
|
-
status.set(
|
|
175
|
+
status.set('disconnected')
|
|
176
176
|
return
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
status.set(
|
|
179
|
+
status.set('connecting')
|
|
180
180
|
|
|
181
181
|
try {
|
|
182
182
|
es = new EventSource(getUrl(), {
|
|
@@ -184,7 +184,7 @@ export function useSSE<T = string>(options: UseSSEOptions<T>): UseSSEResult<T> {
|
|
|
184
184
|
})
|
|
185
185
|
readyState.set(EventSource.CONNECTING)
|
|
186
186
|
} catch {
|
|
187
|
-
status.set(
|
|
187
|
+
status.set('error')
|
|
188
188
|
readyState.set(EventSource.CLOSED)
|
|
189
189
|
scheduleReconnect()
|
|
190
190
|
return
|
|
@@ -192,7 +192,7 @@ export function useSSE<T = string>(options: UseSSEOptions<T>): UseSSEResult<T> {
|
|
|
192
192
|
|
|
193
193
|
es.onopen = (event: Event) => {
|
|
194
194
|
batch(() => {
|
|
195
|
-
status.set(
|
|
195
|
+
status.set('connected')
|
|
196
196
|
error.set(null)
|
|
197
197
|
readyState.set(EventSource.OPEN)
|
|
198
198
|
reconnectAttempts = 0
|
|
@@ -230,7 +230,7 @@ export function useSSE<T = string>(options: UseSSEOptions<T>): UseSSEResult<T> {
|
|
|
230
230
|
es.close()
|
|
231
231
|
es = null
|
|
232
232
|
}
|
|
233
|
-
status.set(
|
|
233
|
+
status.set('disconnected')
|
|
234
234
|
readyState.set(EventSource.CLOSED)
|
|
235
235
|
}
|
|
236
236
|
|
|
@@ -243,8 +243,8 @@ export function useSSE<T = string>(options: UseSSEOptions<T>): UseSSEResult<T> {
|
|
|
243
243
|
// Track reactive URL and enabled state
|
|
244
244
|
effect(() => {
|
|
245
245
|
// Read reactive values to subscribe to changes
|
|
246
|
-
if (typeof options.url ===
|
|
247
|
-
if (typeof options.enabled ===
|
|
246
|
+
if (typeof options.url === 'function') options.url()
|
|
247
|
+
if (typeof options.enabled === 'function') options.enabled()
|
|
248
248
|
|
|
249
249
|
intentionalClose = false
|
|
250
250
|
reconnectAttempts = 0
|
package/src/use-subscription.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { onUnmount } from
|
|
2
|
-
import type { Signal } from
|
|
3
|
-
import { batch, effect, signal } from
|
|
4
|
-
import type { QueryClient } from
|
|
5
|
-
import { useQueryClient } from
|
|
1
|
+
import { onUnmount } from '@pyreon/core'
|
|
2
|
+
import type { Signal } from '@pyreon/reactivity'
|
|
3
|
+
import { batch, effect, signal } from '@pyreon/reactivity'
|
|
4
|
+
import type { QueryClient } from '@tanstack/query-core'
|
|
5
|
+
import { useQueryClient } from './query-client'
|
|
6
6
|
|
|
7
7
|
// ─── Types ───────────────────────────────────────────────────────────────────
|
|
8
8
|
|
|
9
|
-
export type SubscriptionStatus =
|
|
9
|
+
export type SubscriptionStatus = 'connecting' | 'connected' | 'disconnected' | 'error'
|
|
10
10
|
|
|
11
11
|
export interface UseSubscriptionOptions {
|
|
12
12
|
/** WebSocket URL — can be a signal for reactive URLs */
|
|
@@ -68,7 +68,7 @@ export interface UseSubscriptionResult {
|
|
|
68
68
|
*/
|
|
69
69
|
export function useSubscription(options: UseSubscriptionOptions): UseSubscriptionResult {
|
|
70
70
|
const queryClient = useQueryClient()
|
|
71
|
-
const status = signal<SubscriptionStatus>(
|
|
71
|
+
const status = signal<SubscriptionStatus>('disconnected')
|
|
72
72
|
|
|
73
73
|
let ws: WebSocket | null = null
|
|
74
74
|
let reconnectAttempts = 0
|
|
@@ -80,12 +80,12 @@ export function useSubscription(options: UseSubscriptionOptions): UseSubscriptio
|
|
|
80
80
|
const maxAttempts = options.maxReconnectAttempts ?? 10
|
|
81
81
|
|
|
82
82
|
function getUrl(): string {
|
|
83
|
-
return typeof options.url ===
|
|
83
|
+
return typeof options.url === 'function' ? options.url() : options.url
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
function isEnabled(): boolean {
|
|
87
87
|
if (options.enabled === undefined) return true
|
|
88
|
-
return typeof options.enabled ===
|
|
88
|
+
return typeof options.enabled === 'function' ? options.enabled() : options.enabled
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
function connect(): void {
|
|
@@ -100,23 +100,23 @@ export function useSubscription(options: UseSubscriptionOptions): UseSubscriptio
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
if (!isEnabled()) {
|
|
103
|
-
status.set(
|
|
103
|
+
status.set('disconnected')
|
|
104
104
|
return
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
status.set(
|
|
107
|
+
status.set('connecting')
|
|
108
108
|
|
|
109
109
|
try {
|
|
110
110
|
ws = options.protocols ? new WebSocket(getUrl(), options.protocols) : new WebSocket(getUrl())
|
|
111
111
|
} catch {
|
|
112
|
-
status.set(
|
|
112
|
+
status.set('error')
|
|
113
113
|
scheduleReconnect()
|
|
114
114
|
return
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
ws.onopen = (event) => {
|
|
118
118
|
batch(() => {
|
|
119
|
-
status.set(
|
|
119
|
+
status.set('connected')
|
|
120
120
|
reconnectAttempts = 0
|
|
121
121
|
})
|
|
122
122
|
options.onOpen?.(event)
|
|
@@ -131,7 +131,7 @@ export function useSubscription(options: UseSubscriptionOptions): UseSubscriptio
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
ws.onclose = (event) => {
|
|
134
|
-
status.set(
|
|
134
|
+
status.set('disconnected')
|
|
135
135
|
options.onClose?.(event)
|
|
136
136
|
|
|
137
137
|
if (!intentionalClose && reconnectEnabled) {
|
|
@@ -140,7 +140,7 @@ export function useSubscription(options: UseSubscriptionOptions): UseSubscriptio
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
ws.onerror = (event) => {
|
|
143
|
-
status.set(
|
|
143
|
+
status.set('error')
|
|
144
144
|
options.onError?.(event)
|
|
145
145
|
}
|
|
146
146
|
}
|
|
@@ -182,7 +182,7 @@ export function useSubscription(options: UseSubscriptionOptions): UseSubscriptio
|
|
|
182
182
|
}
|
|
183
183
|
ws = null
|
|
184
184
|
}
|
|
185
|
-
status.set(
|
|
185
|
+
status.set('disconnected')
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
function manualReconnect(): void {
|
|
@@ -194,8 +194,8 @@ export function useSubscription(options: UseSubscriptionOptions): UseSubscriptio
|
|
|
194
194
|
// Track reactive URL and enabled state
|
|
195
195
|
effect(() => {
|
|
196
196
|
// Read reactive values to subscribe to changes
|
|
197
|
-
if (typeof options.url ===
|
|
198
|
-
if (typeof options.enabled ===
|
|
197
|
+
if (typeof options.url === 'function') options.url()
|
|
198
|
+
if (typeof options.enabled === 'function') options.enabled()
|
|
199
199
|
|
|
200
200
|
intentionalClose = false
|
|
201
201
|
reconnectAttempts = 0
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { VNodeChild, VNodeChildAtom } from
|
|
2
|
-
import { onUnmount } from
|
|
3
|
-
import type { Signal } from
|
|
4
|
-
import { batch, effect, signal } from
|
|
1
|
+
import type { VNodeChild, VNodeChildAtom } from '@pyreon/core'
|
|
2
|
+
import { onUnmount } from '@pyreon/core'
|
|
3
|
+
import type { Signal } from '@pyreon/reactivity'
|
|
4
|
+
import { batch, effect, signal } from '@pyreon/reactivity'
|
|
5
5
|
import type {
|
|
6
6
|
DefaultError,
|
|
7
7
|
InfiniteData,
|
|
@@ -10,9 +10,9 @@ import type {
|
|
|
10
10
|
QueryKey,
|
|
11
11
|
QueryObserverOptions,
|
|
12
12
|
QueryObserverResult,
|
|
13
|
-
} from
|
|
14
|
-
import { InfiniteQueryObserver, QueryObserver } from
|
|
15
|
-
import { useQueryClient } from
|
|
13
|
+
} from '@tanstack/query-core'
|
|
14
|
+
import { InfiniteQueryObserver, QueryObserver } from '@tanstack/query-core'
|
|
15
|
+
import { useQueryClient } from './query-client'
|
|
16
16
|
|
|
17
17
|
// ─── Types ─────────────────────────────────────────────────────────────────
|
|
18
18
|
|
|
@@ -26,7 +26,7 @@ export interface UseSuspenseQueryResult<TData, TError = DefaultError> {
|
|
|
26
26
|
/** Always TData — never undefined inside a QuerySuspense boundary. */
|
|
27
27
|
data: Signal<TData>
|
|
28
28
|
error: Signal<TError | null>
|
|
29
|
-
status: Signal<
|
|
29
|
+
status: Signal<'pending' | 'error' | 'success'>
|
|
30
30
|
isPending: Signal<boolean>
|
|
31
31
|
isFetching: Signal<boolean>
|
|
32
32
|
isError: Signal<boolean>
|
|
@@ -39,7 +39,7 @@ export interface UseSuspenseInfiniteQueryResult<TQueryFnData, TError = DefaultEr
|
|
|
39
39
|
/** Always InfiniteData<TQueryFnData> — never undefined inside a QuerySuspense boundary. */
|
|
40
40
|
data: Signal<InfiniteData<TQueryFnData>>
|
|
41
41
|
error: Signal<TError | null>
|
|
42
|
-
status: Signal<
|
|
42
|
+
status: Signal<'pending' | 'error' | 'success'>
|
|
43
43
|
isFetching: Signal<boolean>
|
|
44
44
|
isFetchingNextPage: Signal<boolean>
|
|
45
45
|
isFetchingPreviousPage: Signal<boolean>
|
|
@@ -109,13 +109,13 @@ export function QuerySuspense(props: QuerySuspenseProps): VNodeChild {
|
|
|
109
109
|
if (queries.some((q) => q.isPending())) {
|
|
110
110
|
const fb = props.fallback
|
|
111
111
|
return (
|
|
112
|
-
typeof fb ===
|
|
112
|
+
typeof fb === 'function' ? (fb as () => VNodeChildAtom)() : (fb ?? null)
|
|
113
113
|
) as VNodeChildAtom
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
// All success — render children
|
|
117
117
|
const ch = props.children
|
|
118
|
-
return (typeof ch ===
|
|
118
|
+
return (typeof ch === 'function' ? (ch as () => VNodeChildAtom)() : ch) as VNodeChildAtom
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -147,7 +147,7 @@ export function useSuspenseQuery<
|
|
|
147
147
|
const resultSig = signal<QueryObserverResult<TData, TError>>(initial)
|
|
148
148
|
const dataSig = signal<TData>(initial.data as TData)
|
|
149
149
|
const errorSig = signal<TError | null>(initial.error ?? null)
|
|
150
|
-
const statusSig = signal<
|
|
150
|
+
const statusSig = signal<'pending' | 'error' | 'success'>(initial.status)
|
|
151
151
|
const isPending = signal(initial.isPending)
|
|
152
152
|
const isFetching = signal(initial.isFetching)
|
|
153
153
|
const isError = signal(initial.isError)
|