MCPcopy Create free account
hub / github.com/TanStack/query / createDeepSignal

Function createDeepSignal

packages/solid-query/src/useBaseQuery.ts:235–252  ·  view source on GitHub ↗

* Creates the signal used as the resource's storage, backed by the query store. Hydration data is * removed from values written to it. * @returns A getter and setter for the store.

()

Source from the content-addressed store, hash-verified

233 * @returns A getter and setter for the store.
234 */
235 function createDeepSignal<T>(): Signal<T> {
236 return [
237 () => state,
238 (v: any) => {
239 const unwrapped = unwrap(state)
240 if (typeof v === 'function') {
241 v = v(unwrapped)
242 }
243 // Hydration data exists on first load after SSR,
244 // and should be removed from the observer result
245 if (v?.hydrationData) {
246 const { hydrationData, ...rest } = v
247 v = rest
248 }
249 setStateWithReconciliation(v)
250 },
251 ] as Signal<T>
252 }
253
254 /**
255 * Unsubscribe is set lazily, so that we can subscribe after hydration when needed.

Callers

nothing calls this directly

Calls 2

unwrapFunction · 0.85

Tested by

no test coverage detected