snapshot of https://github.com/TanStack/query.git (main, 2026-09-16; blobs > 131072B omitted)
This commit is contained in:
13
integrations/lit-vite/index.html
Normal file
13
integrations/lit-vite/index.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Vite + Lit</title>
|
||||
</head>
|
||||
<body>
|
||||
<lit-query-provider>
|
||||
<lit-query-app></lit-query-app>
|
||||
</lit-query-provider>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
17
integrations/lit-vite/package.json
Normal file
17
integrations/lit-vite/package.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "lit-vite",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "tsc --noEmit && vite build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tanstack/lit-query": "workspace:*",
|
||||
"@tanstack/query-core": "workspace:*",
|
||||
"lit": "^3.3.1",
|
||||
"vite": "^6.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "5.8.3"
|
||||
}
|
||||
}
|
||||
56
integrations/lit-vite/src/main.ts
Normal file
56
integrations/lit-vite/src/main.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { LitElement, html } from 'lit'
|
||||
import {
|
||||
QueryClient,
|
||||
QueryClientProvider,
|
||||
createQueryController,
|
||||
} from '@tanstack/lit-query'
|
||||
|
||||
const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
retry: false,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
class LitQueryProvider extends QueryClientProvider {
|
||||
constructor() {
|
||||
super()
|
||||
this.client = queryClient
|
||||
}
|
||||
|
||||
protected override createRenderRoot(): HTMLElement | DocumentFragment {
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
class LitQueryApp extends LitElement {
|
||||
private readonly query = createQueryController(this, {
|
||||
queryKey: ['test'],
|
||||
queryFn: async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 100))
|
||||
return 'Success'
|
||||
},
|
||||
})
|
||||
|
||||
protected override createRenderRoot(): HTMLElement | DocumentFragment {
|
||||
return this
|
||||
}
|
||||
|
||||
render() {
|
||||
const query = this.query()
|
||||
|
||||
if (query.isPending) {
|
||||
return html`<div>Loading...</div>`
|
||||
}
|
||||
|
||||
if (query.isError) {
|
||||
return html`<div>An error has occurred!</div>`
|
||||
}
|
||||
|
||||
return html`<div>${query.data}</div>`
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define('lit-query-provider', LitQueryProvider)
|
||||
customElements.define('lit-query-app', LitQueryApp)
|
||||
14
integrations/lit-vite/tsconfig.json
Normal file
14
integrations/lit-vite/tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
"lib": ["ES2022", "DOM"],
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"isolatedModules": true,
|
||||
"skipLibCheck": true,
|
||||
"useDefineForClassFields": false
|
||||
},
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
3
integrations/lit-vite/vite.config.ts
Normal file
3
integrations/lit-vite/vite.config.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { defineConfig } from 'vite'
|
||||
|
||||
export default defineConfig({})
|
||||
Reference in New Issue
Block a user