| 43 | * @param client - The query client registration to release. |
| 44 | */ |
| 45 | export function unregisterDefaultQueryClient(client: QueryClient): void { |
| 46 | const count = registeredClients.get(client) |
| 47 | if (count === undefined) { |
| 48 | return |
| 49 | } |
| 50 | |
| 51 | if (count > 1) { |
| 52 | registeredClients.set(client, count - 1) |
| 53 | return |
| 54 | } |
| 55 | |
| 56 | registeredClients.delete(client) |
| 57 | if (defaultClient !== client) { |
| 58 | return |
| 59 | } |
| 60 | |
| 61 | const remaining = [...registeredClients.keys()] |
| 62 | defaultClient = remaining.at(-1) |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Returns the registered default `QueryClient`, if exactly one default client is |