* 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.
()
| 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. |
nothing calls this directly
no test coverage detected