Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

Context.ts

41 lines1.1 KB

1import { createContext, useContext } from 'solid-js'
2import type { Query, QueryClient, onlineManager } from '@tanstack/query-core'
3​
4type XPosition = 'left' | 'right'
5type YPosition = 'top' | 'bottom'
6export type DevtoolsPosition = XPosition | YPosition
7export type DevtoolsButtonPosition = `${YPosition}-${XPosition}`
8​
9export interface DevToolsErrorType {
10 /**
11 * The name of the error.
12 */
13 name: string
14 /**
15 * How the error is initialized.
16 */
17 initializer: (query: Query) => Error
19​
20export interface QueryDevtoolsProps {
21 readonly client: QueryClient
22 queryFlavor: string
23 version: string
24 onlineManager: typeof onlineManager
25​
26 buttonPosition?: DevtoolsButtonPosition
27 position?: DevtoolsPosition
28 initialIsOpen?: boolean
29 errorTypes?: Array<DevToolsErrorType>
31​
32export const QueryDevtoolsContext = createContext<QueryDevtoolsProps>({
33 client: undefined as unknown as QueryClient,
34 onlineManager: undefined as unknown as typeof onlineManager,
35 queryFlavor: '',
36 version: '',
37})
38​
39export function useQueryDevtoolsContext() {
40 return useContext(QueryDevtoolsContext)