-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
Copy pathContext.ts
41 lines (35 loc) · 1.07 KB
/
Context.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import type { QueryClient, onlineManager, Query } from '@tanstack/query-core'
import { createContext, useContext } from 'solid-js'
type XPosition = 'left' | 'right'
type YPosition = 'top' | 'bottom'
export type DevtoolsPosition = XPosition | YPosition
export type DevtoolsButtonPosition = `${YPosition}-${XPosition}`
export interface DevToolsErrorType {
/**
* The name of the error.
*/
name: string
/**
* How the error is initialized.
*/
initializer: (query: Query) => Error
}
export interface QueryDevtoolsProps {
readonly client: QueryClient
queryFlavor: string
version: string
onlineManager: typeof onlineManager
buttonPosition?: DevtoolsButtonPosition
position?: DevtoolsPosition
initialIsOpen?: boolean
errorTypes?: DevToolsErrorType[]
}
export const QueryDevtoolsContext = createContext<QueryDevtoolsProps>({
client: undefined as unknown as QueryClient,
onlineManager: undefined as unknown as typeof onlineManager,
queryFlavor: '',
version: '',
})
export function useQueryDevtoolsContext() {
return useContext(QueryDevtoolsContext)
}