(
observer: QueryObserver<Array<any>, any, Array<any>, Array<any>, any>,
hashedQueryKey: string,
)
| 1407 | } |
| 1408 | |
| 1409 | const subscribeToQuery = ( |
| 1410 | observer: QueryObserver<Array<any>, any, Array<any>, Array<any>, any>, |
| 1411 | hashedQueryKey: string, |
| 1412 | ) => { |
| 1413 | if (!isSubscribed(hashedQueryKey)) { |
| 1414 | const cachedQueryKey = hashToQueryKey.get(hashedQueryKey)! |
| 1415 | const handleQueryResult = makeQueryResultHandler(cachedQueryKey) |
| 1416 | const unsubscribeFn = observer.subscribe(handleQueryResult) |
| 1417 | unsubscribes.set(hashedQueryKey, unsubscribeFn) |
| 1418 | |
| 1419 | // Process the current result immediately if available |
| 1420 | // This ensures data is synced when resubscribing to a query with cached data |
| 1421 | const currentResult = observer.getCurrentResult() |
| 1422 | if (currentResult.isSuccess || currentResult.isError) { |
| 1423 | handleQueryResult(currentResult) |
| 1424 | } |
| 1425 | } |
| 1426 | } |
| 1427 | |
| 1428 | const subscribeToQueries = () => { |
| 1429 | state.observers.forEach(subscribeToQuery) |
no test coverage detected