()
| 205 | } |
| 206 | |
| 207 | function createDeepSignal<T>(): Signal<T> { |
| 208 | return [ |
| 209 | () => state, |
| 210 | (v: any) => { |
| 211 | const unwrapped = unwrap(state) |
| 212 | if (typeof v === 'function') { |
| 213 | v = v(unwrapped) |
| 214 | } |
| 215 | // Hydration data exists on first load after SSR, |
| 216 | // and should be removed from the observer result |
| 217 | if (v?.hydrationData) { |
| 218 | const { hydrationData, ...rest } = v |
| 219 | v = rest |
| 220 | } |
| 221 | setStateWithReconciliation(v) |
| 222 | }, |
| 223 | ] as Signal<T> |
| 224 | } |
| 225 | |
| 226 | /** |
| 227 | * Unsubscribe is set lazily, so that we can subscribe after hydration when needed. |
nothing calls this directly
no test coverage detected