@tanstack/lit-query 0.2.24 → 0.2.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/legacy/index.cjs +2 -2
- package/build/legacy/index.cjs.map +1 -1
- package/build/legacy/index.d.cts +21 -21
- package/build/legacy/index.d.cts.map +1 -1
- package/build/legacy/index.d.ts +21 -21
- package/build/legacy/index.d.ts.map +1 -1
- package/build/legacy/index.js +2 -2
- package/build/legacy/index.js.map +1 -1
- package/build/modern/index.cjs +2 -2
- package/build/modern/index.cjs.map +1 -1
- package/build/modern/index.d.cts +21 -21
- package/build/modern/index.d.cts.map +1 -1
- package/build/modern/index.d.ts +21 -21
- package/build/modern/index.d.ts.map +1 -1
- package/build/modern/index.js +2 -2
- package/build/modern/index.js.map +1 -1
- package/package.json +17 -19
- package/src/QueryClientProvider.ts +4 -2
- package/src/controllers/BaseController.ts +3 -2
- package/src/createInfiniteQueryController.ts +13 -17
- package/src/createMutationController.ts +14 -31
- package/src/createQueriesController.ts +21 -26
- package/src/createQueryController.ts +13 -23
- package/src/useIsFetching.ts +3 -7
- package/src/useIsMutating.ts +3 -7
- package/src/useMutationState.ts +13 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/lit-query",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.26",
|
|
4
4
|
"description": "Lit adapter for TanStack Query Core",
|
|
5
5
|
"author": "tannerlinsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,37 +36,35 @@
|
|
|
36
36
|
"files": [
|
|
37
37
|
"build",
|
|
38
38
|
"src",
|
|
39
|
-
"!src/
|
|
39
|
+
"!src/__tests__"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@lit/context": "^1.1.6",
|
|
43
|
-
"@tanstack/query-core": "5.
|
|
43
|
+
"@tanstack/query-core": "5.104.1",
|
|
44
44
|
"lit": "^3.3.3"
|
|
45
45
|
},
|
|
46
|
-
"peerDependencies": {
|
|
47
|
-
"@tanstack/query-core": "^5.103.3",
|
|
48
|
-
"lit": ">=2.8.0 <4"
|
|
49
|
-
},
|
|
50
46
|
"devDependencies": {
|
|
51
|
-
"@eslint/js": "^9.36.0",
|
|
52
47
|
"@tanstack/query-test-utils": "0.0.0",
|
|
53
|
-
"
|
|
54
|
-
|
|
48
|
+
"typescript": "6.0.3"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@tanstack/query-core": "^5.104.1",
|
|
52
|
+
"lit": ">=2.8.0 <4"
|
|
55
53
|
},
|
|
56
54
|
"scripts": {
|
|
57
55
|
"clean": "premove ./build ./coverage ./dist-ts ./.cache/test-types",
|
|
58
56
|
"compile": "tsc --project tsconfig.json",
|
|
59
|
-
"test:eslint": "eslint --concurrency=auto
|
|
60
|
-
"
|
|
61
|
-
"test:types": "tsc --
|
|
57
|
+
"test:eslint": "eslint --concurrency=auto ./src",
|
|
58
|
+
"test:types": "npm-run-all --serial test:types:*",
|
|
59
|
+
"test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js --project tsconfig.legacy.json --outDir .cache/test-types/ts56 --tsBuildInfoFile .cache/test-types/ts56.tsbuildinfo",
|
|
60
|
+
"test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js --project tsconfig.legacy.json --outDir .cache/test-types/ts57 --tsBuildInfoFile .cache/test-types/ts57.tsbuildinfo",
|
|
61
|
+
"test:types:ts58": "node ../../node_modules/typescript58/lib/tsc.js --project tsconfig.legacy.json --outDir .cache/test-types/ts58 --tsBuildInfoFile .cache/test-types/ts58.tsbuildinfo",
|
|
62
|
+
"test:types:ts59": "node ../../node_modules/typescript59/lib/tsc.js --project tsconfig.legacy.json --outDir .cache/test-types/ts59 --tsBuildInfoFile .cache/test-types/ts59.tsbuildinfo",
|
|
63
|
+
"test:types:tscurrent": "tsc --project tsconfig.json --outDir .cache/test-types/tscurrent --tsBuildInfoFile .cache/test-types/tscurrent.tsbuildinfo",
|
|
64
|
+
"test:types:ts70": "node ../../node_modules/typescript70/lib/tsc.js --project tsconfig.legacy.json --outDir .cache/test-types/ts70 --tsBuildInfoFile .cache/test-types/ts70.tsbuildinfo",
|
|
62
65
|
"test:lib": "vitest",
|
|
63
66
|
"test:lib:dev": "pnpm run test:lib --watch",
|
|
64
|
-
"test:watch": "pnpm run test:lib:dev",
|
|
65
67
|
"test:build": "publint --strict && attw --pack",
|
|
66
|
-
"build": "tsdown --tsconfig tsconfig.prod.json"
|
|
67
|
-
"measure:bundle": "pnpm run build && node scripts/measure-bundle.mjs",
|
|
68
|
-
"measure:bundle:raw": "node scripts/measure-bundle.mjs",
|
|
69
|
-
"perf:l3": "pnpm run build && node scripts/l3-stress.mjs",
|
|
70
|
-
"perf:l3:raw": "node scripts/l3-stress.mjs"
|
|
68
|
+
"build": "tsdown --tsconfig tsconfig.prod.json"
|
|
71
69
|
}
|
|
72
70
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { ContextProvider } from '@lit/context'
|
|
2
|
-
import type { QueryClient } from '@tanstack/query-core'
|
|
3
|
-
import type { TemplateResult } from 'lit'
|
|
4
2
|
import { LitElement, html } from 'lit'
|
|
5
3
|
import {
|
|
6
4
|
createMissingQueryClientError,
|
|
@@ -8,6 +6,8 @@ import {
|
|
|
8
6
|
registerDefaultQueryClient,
|
|
9
7
|
unregisterDefaultQueryClient,
|
|
10
8
|
} from './context.js'
|
|
9
|
+
import type { QueryClient } from '@tanstack/query-core'
|
|
10
|
+
import type { TemplateResult } from 'lit'
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Lit element that provides a `QueryClient` to descendant Lit Query
|
|
@@ -107,6 +107,7 @@ export class QueryClientProvider extends LitElement {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
const nextClient = this.client
|
|
110
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
110
111
|
if (!nextClient) {
|
|
111
112
|
if (this.isConnected) {
|
|
112
113
|
this.unmountClient(this.mountedClient)
|
|
@@ -164,6 +165,7 @@ export class QueryClientProvider extends LitElement {
|
|
|
164
165
|
}
|
|
165
166
|
|
|
166
167
|
private requireClient(): QueryClient {
|
|
168
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
167
169
|
if (!this.client) {
|
|
168
170
|
throw createMissingQueryClientError()
|
|
169
171
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ContextEvent } from '@lit/context'
|
|
2
|
-
import type { QueryClient } from '@tanstack/query-core'
|
|
3
|
-
import type { ReactiveController, ReactiveControllerHost } from 'lit'
|
|
4
2
|
import {
|
|
5
3
|
createMissingQueryClientError,
|
|
6
4
|
queryClientContext,
|
|
7
5
|
} from '../context.js'
|
|
6
|
+
import type { QueryClient } from '@tanstack/query-core'
|
|
7
|
+
import type { ReactiveController, ReactiveControllerHost } from 'lit'
|
|
8
8
|
|
|
9
9
|
type QueryClientResolutionState =
|
|
10
10
|
'pre-connect' | 'awaiting-context' | 'bound' | 'missing'
|
|
@@ -230,6 +230,7 @@ export abstract class BaseController<TResult> implements ReactiveController {
|
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
const resolutionChanged = this.updateQueryClientResolutionState(
|
|
233
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
233
234
|
value === undefined ? 'missing' : 'bound',
|
|
234
235
|
)
|
|
235
236
|
const clientChanged = this.contextClient !== value
|
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
type DefaultError,
|
|
4
|
-
type DefaultedInfiniteQueryObserverOptions,
|
|
5
|
-
type InfiniteData,
|
|
6
|
-
type InfiniteQueryObserverOptions,
|
|
7
|
-
type InfiniteQueryObserverResult,
|
|
8
|
-
type QueryKey,
|
|
9
|
-
} from '@tanstack/query-core'
|
|
10
|
-
import type { QueryClient } from '@tanstack/query-core'
|
|
11
|
-
import type { ReactiveControllerHost } from 'lit'
|
|
12
|
-
import {
|
|
13
|
-
createValueAccessor,
|
|
14
|
-
readAccessor,
|
|
15
|
-
type Accessor,
|
|
16
|
-
type ValueAccessor,
|
|
17
|
-
} from './accessor.js'
|
|
1
|
+
import { InfiniteQueryObserver } from '@tanstack/query-core'
|
|
2
|
+
import { createValueAccessor, readAccessor } from './accessor.js'
|
|
18
3
|
import { createMissingQueryClientError } from './context.js'
|
|
19
4
|
import { BaseController } from './controllers/BaseController.js'
|
|
20
5
|
import { QueryObserverResultTracker } from './queryObserverResultTracker.js'
|
|
6
|
+
import type { Accessor, ValueAccessor } from './accessor.js'
|
|
7
|
+
import type {
|
|
8
|
+
DefaultError,
|
|
9
|
+
DefaultedInfiniteQueryObserverOptions,
|
|
10
|
+
InfiniteData,
|
|
11
|
+
InfiniteQueryObserverOptions,
|
|
12
|
+
InfiniteQueryObserverResult,
|
|
13
|
+
QueryClient,
|
|
14
|
+
QueryKey,
|
|
15
|
+
} from '@tanstack/query-core'
|
|
16
|
+
import type { ReactiveControllerHost } from 'lit'
|
|
21
17
|
|
|
22
18
|
/**
|
|
23
19
|
* Options accepted by `createInfiniteQueryController`.
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
type DefaultError,
|
|
4
|
-
type MutateFunction,
|
|
5
|
-
type MutationObserverOptions,
|
|
6
|
-
type MutationObserverResult,
|
|
7
|
-
} from '@tanstack/query-core'
|
|
8
|
-
import type { QueryClient } from '@tanstack/query-core'
|
|
9
|
-
import type { ReactiveControllerHost } from 'lit'
|
|
10
|
-
import {
|
|
11
|
-
createValueAccessor,
|
|
12
|
-
readAccessor,
|
|
13
|
-
type Accessor,
|
|
14
|
-
type ValueAccessor,
|
|
15
|
-
} from './accessor.js'
|
|
1
|
+
import { MutationObserver } from '@tanstack/query-core'
|
|
2
|
+
import { createValueAccessor, readAccessor } from './accessor.js'
|
|
16
3
|
import { createMissingQueryClientError } from './context.js'
|
|
17
4
|
import { BaseController } from './controllers/BaseController.js'
|
|
5
|
+
import type { Accessor, ValueAccessor } from './accessor.js'
|
|
6
|
+
import type {
|
|
7
|
+
DefaultError,
|
|
8
|
+
MutateFunction,
|
|
9
|
+
MutationObserverOptions,
|
|
10
|
+
MutationObserverResult,
|
|
11
|
+
QueryClient,
|
|
12
|
+
} from '@tanstack/query-core'
|
|
13
|
+
import type { ReactiveControllerHost } from 'lit'
|
|
18
14
|
|
|
19
15
|
/**
|
|
20
16
|
* Options accepted by `createMutationController`.
|
|
@@ -91,22 +87,9 @@ function createIdleMutationResult<
|
|
|
91
87
|
status: 'idle',
|
|
92
88
|
submittedAt: 0,
|
|
93
89
|
variables: undefined,
|
|
94
|
-
mutate: (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
)) as MutationObserverResult<
|
|
98
|
-
TData,
|
|
99
|
-
TError,
|
|
100
|
-
TVariables,
|
|
101
|
-
TOnMutateResult
|
|
102
|
-
>['mutate'],
|
|
103
|
-
reset: (() => undefined) as MutationObserverResult<
|
|
104
|
-
TData,
|
|
105
|
-
TError,
|
|
106
|
-
TVariables,
|
|
107
|
-
TOnMutateResult
|
|
108
|
-
>['reset'],
|
|
109
|
-
} as MutationObserverResult<TData, TError, TVariables, TOnMutateResult>
|
|
90
|
+
mutate: () => Promise.reject(createMissingQueryClientError()),
|
|
91
|
+
reset: () => undefined,
|
|
92
|
+
}
|
|
110
93
|
}
|
|
111
94
|
|
|
112
95
|
class MutationController<
|
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
replaceEqualDeep,
|
|
4
|
-
type DefaultError,
|
|
5
|
-
type DefinedQueryObserverResult,
|
|
6
|
-
type OmitKeyof,
|
|
7
|
-
type QueriesObserverOptions,
|
|
8
|
-
type QueryFunction,
|
|
9
|
-
type QueryKey,
|
|
10
|
-
type QueryObserverOptions,
|
|
11
|
-
type QueryObserverResult,
|
|
12
|
-
type ThrowOnError,
|
|
13
|
-
} from '@tanstack/query-core'
|
|
14
|
-
import type { QueryClient } from '@tanstack/query-core'
|
|
15
|
-
import type { ReactiveControllerHost } from 'lit'
|
|
16
|
-
import {
|
|
17
|
-
createValueAccessor,
|
|
18
|
-
readAccessor,
|
|
19
|
-
type Accessor,
|
|
20
|
-
type ValueAccessor,
|
|
21
|
-
} from './accessor.js'
|
|
1
|
+
import { QueriesObserver, replaceEqualDeep } from '@tanstack/query-core'
|
|
2
|
+
import { createValueAccessor, readAccessor } from './accessor.js'
|
|
22
3
|
import { createMissingQueryClientError } from './context.js'
|
|
23
4
|
import { BaseController } from './controllers/BaseController.js'
|
|
5
|
+
import type { Accessor, ValueAccessor } from './accessor.js'
|
|
6
|
+
import type {
|
|
7
|
+
DefaultError,
|
|
8
|
+
DefinedQueryObserverResult,
|
|
9
|
+
OmitKeyof,
|
|
10
|
+
QueriesObserverOptions,
|
|
11
|
+
QueryClient,
|
|
12
|
+
QueryFunction,
|
|
13
|
+
QueryKey,
|
|
14
|
+
QueryObserverOptions,
|
|
15
|
+
QueryObserverResult,
|
|
16
|
+
ThrowOnError,
|
|
17
|
+
} from '@tanstack/query-core'
|
|
18
|
+
import type { ReactiveControllerHost } from 'lit'
|
|
24
19
|
|
|
25
20
|
/**
|
|
26
21
|
* Options for one query inside `createQueriesController`.
|
|
@@ -411,7 +406,7 @@ class QueriesController<
|
|
|
411
406
|
this.combine = combine
|
|
412
407
|
const observer = new QueriesObserver(queryClient, this.queries, {
|
|
413
408
|
combine: this.combine,
|
|
414
|
-
}
|
|
409
|
+
})
|
|
415
410
|
this.queryClient = queryClient
|
|
416
411
|
this.observer = observer
|
|
417
412
|
this.assignObserverResult(observer.getCurrentResult(), true)
|
|
@@ -471,7 +466,7 @@ class QueriesController<
|
|
|
471
466
|
this.combine = combine
|
|
472
467
|
this.observer = new QueriesObserver(this.queryClient, this.queries, {
|
|
473
468
|
combine: this.combine,
|
|
474
|
-
}
|
|
469
|
+
})
|
|
475
470
|
this.setObserverResult(this.observer.getCurrentResult(), true)
|
|
476
471
|
this.placeholderInitialized = true
|
|
477
472
|
return true
|
|
@@ -488,7 +483,7 @@ class QueriesController<
|
|
|
488
483
|
|
|
489
484
|
this.observer.setQueries(this.queries, {
|
|
490
485
|
combine: this.combine,
|
|
491
|
-
}
|
|
486
|
+
})
|
|
492
487
|
|
|
493
488
|
this.setObserverResult(this.observer.getCurrentResult(), true)
|
|
494
489
|
return true
|
|
@@ -529,7 +524,7 @@ class QueriesController<
|
|
|
529
524
|
this.combinedResult = replaceEqualDeep(
|
|
530
525
|
this.combinedResult,
|
|
531
526
|
combine(trackedResult),
|
|
532
|
-
)
|
|
527
|
+
)
|
|
533
528
|
|
|
534
529
|
return this.combinedResult
|
|
535
530
|
}
|
|
@@ -613,7 +608,7 @@ class QueriesController<
|
|
|
613
608
|
)
|
|
614
609
|
return (
|
|
615
610
|
resolvedOptions.combine
|
|
616
|
-
? resolvedOptions.combine(placeholders
|
|
611
|
+
? resolvedOptions.combine(placeholders)
|
|
617
612
|
: placeholders
|
|
618
613
|
) as TCombinedResult
|
|
619
614
|
}
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
type DefaultError,
|
|
4
|
-
type DefaultedQueryObserverOptions,
|
|
5
|
-
type QueryKey,
|
|
6
|
-
type QueryObserverOptions,
|
|
7
|
-
type QueryObserverResult,
|
|
8
|
-
} from '@tanstack/query-core'
|
|
9
|
-
import type { QueryClient } from '@tanstack/query-core'
|
|
10
|
-
import type { ReactiveControllerHost } from 'lit'
|
|
11
|
-
import {
|
|
12
|
-
createValueAccessor,
|
|
13
|
-
readAccessor,
|
|
14
|
-
type Accessor,
|
|
15
|
-
type ValueAccessor,
|
|
16
|
-
} from './accessor.js'
|
|
1
|
+
import { QueryObserver } from '@tanstack/query-core'
|
|
2
|
+
import { createValueAccessor, readAccessor } from './accessor.js'
|
|
17
3
|
import { createMissingQueryClientError } from './context.js'
|
|
18
4
|
import { BaseController } from './controllers/BaseController.js'
|
|
19
5
|
import { QueryObserverResultTracker } from './queryObserverResultTracker.js'
|
|
6
|
+
import type { Accessor, ValueAccessor } from './accessor.js'
|
|
7
|
+
import type {
|
|
8
|
+
DefaultError,
|
|
9
|
+
DefaultedQueryObserverOptions,
|
|
10
|
+
QueryClient,
|
|
11
|
+
QueryKey,
|
|
12
|
+
QueryObserverOptions,
|
|
13
|
+
QueryObserverResult,
|
|
14
|
+
} from '@tanstack/query-core'
|
|
15
|
+
import type { ReactiveControllerHost } from 'lit'
|
|
20
16
|
|
|
21
17
|
/**
|
|
22
18
|
* Options accepted by `createQueryController`.
|
|
@@ -300,13 +296,7 @@ class QueryController<
|
|
|
300
296
|
this.queryClient = resolvedClient
|
|
301
297
|
const defaulted = resolvedClient.defaultQueryOptions(
|
|
302
298
|
readAccessor(this.options),
|
|
303
|
-
)
|
|
304
|
-
TQueryFnData,
|
|
305
|
-
TError,
|
|
306
|
-
TData,
|
|
307
|
-
TQueryData,
|
|
308
|
-
TQueryKey
|
|
309
|
-
>
|
|
299
|
+
)
|
|
310
300
|
;(defaulted as { _optimisticResults?: 'optimistic' })._optimisticResults =
|
|
311
301
|
'optimistic'
|
|
312
302
|
return defaulted
|
package/src/useIsFetching.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
+
import { createValueAccessor, readAccessor } from './accessor.js'
|
|
2
|
+
import { BaseController } from './controllers/BaseController.js'
|
|
3
|
+
import type { Accessor, ValueAccessor } from './accessor.js'
|
|
1
4
|
import type { QueryClient, QueryFilters } from '@tanstack/query-core'
|
|
2
5
|
import type { ReactiveControllerHost } from 'lit'
|
|
3
|
-
import {
|
|
4
|
-
createValueAccessor,
|
|
5
|
-
readAccessor,
|
|
6
|
-
type Accessor,
|
|
7
|
-
type ValueAccessor,
|
|
8
|
-
} from './accessor.js'
|
|
9
|
-
import { BaseController } from './controllers/BaseController.js'
|
|
10
6
|
|
|
11
7
|
/**
|
|
12
8
|
* Accessor returned by `useIsFetching`.
|
package/src/useIsMutating.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
+
import { createValueAccessor, readAccessor } from './accessor.js'
|
|
2
|
+
import { BaseController } from './controllers/BaseController.js'
|
|
3
|
+
import type { Accessor, ValueAccessor } from './accessor.js'
|
|
1
4
|
import type { MutationFilters, QueryClient } from '@tanstack/query-core'
|
|
2
5
|
import type { ReactiveControllerHost } from 'lit'
|
|
3
|
-
import {
|
|
4
|
-
createValueAccessor,
|
|
5
|
-
readAccessor,
|
|
6
|
-
type Accessor,
|
|
7
|
-
type ValueAccessor,
|
|
8
|
-
} from './accessor.js'
|
|
9
|
-
import { BaseController } from './controllers/BaseController.js'
|
|
10
6
|
|
|
11
7
|
/**
|
|
12
8
|
* Accessor returned by `useIsMutating`.
|
package/src/useMutationState.ts
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { replaceEqualDeep } from '@tanstack/query-core'
|
|
2
|
+
import { createValueAccessor, readAccessor } from './accessor.js'
|
|
3
|
+
import { BaseController } from './controllers/BaseController.js'
|
|
4
|
+
import type { Accessor, ValueAccessor } from './accessor.js'
|
|
5
|
+
import type {
|
|
6
|
+
Mutation,
|
|
7
|
+
MutationFilters,
|
|
8
|
+
MutationState,
|
|
9
|
+
QueryClient,
|
|
7
10
|
} from '@tanstack/query-core'
|
|
8
11
|
import type { ReactiveControllerHost } from 'lit'
|
|
9
|
-
import {
|
|
10
|
-
createValueAccessor,
|
|
11
|
-
readAccessor,
|
|
12
|
-
type Accessor,
|
|
13
|
-
type ValueAccessor,
|
|
14
|
-
} from './accessor.js'
|
|
15
|
-
import { BaseController } from './controllers/BaseController.js'
|
|
16
12
|
|
|
17
13
|
/**
|
|
18
14
|
* Options accepted by `useMutationState`.
|
|
@@ -30,12 +26,12 @@ export type MutationStateOptions<TResult> = {
|
|
|
30
26
|
* Call the accessor or read its `current` property to get the selected state for
|
|
31
27
|
* matching mutations.
|
|
32
28
|
*/
|
|
33
|
-
export type MutationStateAccessor<TResult> = ValueAccessor<TResult
|
|
29
|
+
export type MutationStateAccessor<TResult> = ValueAccessor<Array<TResult>> & {
|
|
34
30
|
/** Removes the controller from its Lit host and unsubscribes observers. */
|
|
35
31
|
destroy: () => void
|
|
36
32
|
}
|
|
37
33
|
|
|
38
|
-
class MutationStateController<TResult> extends BaseController<TResult
|
|
34
|
+
class MutationStateController<TResult> extends BaseController<Array<TResult>> {
|
|
39
35
|
private queryClient: QueryClient | undefined
|
|
40
36
|
private unsubscribe: (() => void) | undefined
|
|
41
37
|
|
|
@@ -123,7 +119,7 @@ class MutationStateController<TResult> extends BaseController<TResult[]> {
|
|
|
123
119
|
})
|
|
124
120
|
}
|
|
125
121
|
|
|
126
|
-
private setMutationState(next: TResult
|
|
122
|
+
private setMutationState(next: Array<TResult>): void {
|
|
127
123
|
this.setResult(replaceEqualDeep(this.result, next))
|
|
128
124
|
}
|
|
129
125
|
|
|
@@ -134,7 +130,7 @@ class MutationStateController<TResult> extends BaseController<TResult[]> {
|
|
|
134
130
|
)
|
|
135
131
|
}
|
|
136
132
|
|
|
137
|
-
private computeState(): TResult
|
|
133
|
+
private computeState(): Array<TResult> {
|
|
138
134
|
if (!this.queryClient) {
|
|
139
135
|
return []
|
|
140
136
|
}
|