@fozy-labs/rx-toolkit 0.5.4 → 0.6.0
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/LICENSE +1 -1
- package/README.md +22 -13
- package/dist/common/devtools/reduxDevtools.js +17 -2
- package/dist/common/react/index.d.ts +1 -0
- package/dist/common/react/index.js +1 -0
- package/dist/common/react/useIsomorphicLayoutEffect.d.ts +17 -0
- package/dist/common/react/useIsomorphicLayoutEffect.js +17 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/query/api/createApi.d.ts +4 -0
- package/dist/query/api/createApi.js +9 -0
- package/dist/query/api/index.d.ts +1 -0
- package/dist/query/api/index.js +1 -0
- package/dist/query/constants.d.ts +12 -0
- package/dist/query/constants.js +15 -0
- package/dist/query/core/api/Api.d.ts +20 -0
- package/dist/query/core/api/Api.js +129 -0
- package/dist/query/core/api/constants.d.ts +2 -0
- package/dist/query/core/api/constants.js +3 -0
- package/dist/query/core/api/index.d.ts +4 -0
- package/dist/query/core/api/index.js +4 -0
- package/dist/query/core/api/mergeHooks.d.ts +2 -0
- package/dist/query/core/api/mergeHooks.js +26 -0
- package/dist/query/core/api/normalizeLinks.d.ts +2 -0
- package/dist/query/core/api/normalizeLinks.js +11 -0
- package/dist/query/core/cache/CacheEntry.d.ts +21 -0
- package/dist/query/core/cache/CacheEntry.js +54 -0
- package/dist/query/core/cache/CacheMap.d.ts +19 -0
- package/dist/query/core/cache/CacheMap.js +32 -0
- package/dist/query/core/cache/QueryCacheEntry.d.ts +21 -0
- package/dist/query/core/cache/QueryCacheEntry.js +136 -0
- package/dist/query/core/cache/index.d.ts +3 -0
- package/dist/query/core/cache/index.js +3 -0
- package/dist/query/core/command/Command.d.ts +67 -0
- package/dist/query/core/command/Command.js +253 -0
- package/dist/query/core/command/CommandAgent.d.ts +17 -0
- package/dist/query/core/command/CommandAgent.js +67 -0
- package/dist/query/core/command/LinkManager.d.ts +24 -0
- package/dist/query/core/command/LinkManager.js +71 -0
- package/dist/query/core/command/index.d.ts +2 -0
- package/dist/query/core/command/index.js +2 -0
- package/dist/query/core/errors/CacheEntryRemovedError.d.ts +7 -0
- package/dist/query/core/errors/CacheEntryRemovedError.js +9 -0
- package/dist/query/core/errors/MachineStateError.d.ts +8 -0
- package/dist/query/core/errors/MachineStateError.js +10 -0
- package/dist/query/core/errors/MachineTransitionError.d.ts +7 -0
- package/dist/query/core/errors/MachineTransitionError.js +9 -0
- package/dist/query/core/errors/index.d.ts +3 -0
- package/dist/query/core/errors/index.js +3 -0
- package/dist/query/core/index.d.ts +8 -0
- package/dist/query/core/index.js +8 -0
- package/dist/query/core/machine/Machine.d.ts +21 -0
- package/dist/query/core/machine/Machine.js +42 -0
- package/dist/query/core/machine/MachineBase.d.ts +31 -0
- package/dist/query/core/machine/MachineBase.js +176 -0
- package/dist/query/core/machine/MachineError.d.ts +10 -0
- package/dist/query/core/machine/MachineError.js +19 -0
- package/dist/query/core/machine/MachinePending.d.ts +13 -0
- package/dist/query/core/machine/MachinePending.js +32 -0
- package/dist/query/core/machine/MachineRefreshError.d.ts +12 -0
- package/dist/query/core/machine/MachineRefreshError.js +23 -0
- package/dist/query/core/machine/MachineRefreshing.d.ts +15 -0
- package/dist/query/core/machine/MachineRefreshing.js +43 -0
- package/dist/query/core/machine/MachineSuccess.d.ts +12 -0
- package/dist/query/core/machine/MachineSuccess.js +23 -0
- package/dist/query/core/machine/MachineWithData.d.ts +25 -0
- package/dist/query/core/machine/MachineWithData.js +73 -0
- package/dist/query/core/machine/index.d.ts +9 -0
- package/dist/query/core/machine/index.js +9 -0
- package/dist/query/core/machine/machine-helpers.d.ts +9 -0
- package/dist/query/core/machine/machine-helpers.js +80 -0
- package/dist/query/core/patcher/Patcher.d.ts +30 -0
- package/dist/query/core/patcher/Patcher.js +122 -0
- package/dist/query/core/patcher/index.d.ts +1 -0
- package/dist/query/core/patcher/index.js +1 -0
- package/dist/query/core/resource/Resource.d.ts +105 -0
- package/dist/query/core/resource/Resource.js +340 -0
- package/dist/query/core/resource/ResourceAgent.d.ts +37 -0
- package/dist/query/core/resource/ResourceAgent.js +179 -0
- package/dist/query/core/resource/index.d.ts +2 -0
- package/dist/query/core/resource/index.js +2 -0
- package/dist/query/core/snapshoter/Snapshoter.d.ts +22 -0
- package/dist/query/core/snapshoter/Snapshoter.js +78 -0
- package/dist/query/core/snapshoter/index.d.ts +2 -0
- package/dist/query/core/snapshoter/index.js +1 -0
- package/dist/query/core/syncer/Syncer.d.ts +32 -0
- package/dist/query/core/syncer/Syncer.js +85 -0
- package/dist/query/core/syncer/index.d.ts +2 -0
- package/dist/query/core/syncer/index.js +1 -0
- package/dist/query/index.d.ts +5 -10
- package/dist/query/index.js +5 -13
- package/dist/query/lib/broadcastSyncDriver.d.ts +5 -0
- package/dist/query/lib/broadcastSyncDriver.js +46 -0
- package/dist/query/lib/index.d.ts +3 -0
- package/dist/query/lib/index.js +3 -0
- package/dist/{query-v2 → query}/lib/stableStringify.js +5 -3
- package/dist/query/lib/toKeyed.d.ts +11 -0
- package/dist/query/lib/toKeyed.js +18 -0
- package/dist/query/react/ReactHooksPlugin.d.ts +31 -0
- package/dist/query/react/ReactHooksPlugin.js +21 -0
- package/dist/query/react/index.d.ts +3 -0
- package/dist/query/react/index.js +3 -0
- package/dist/query/react/useCommand.d.ts +2 -0
- package/dist/query/react/useCommand.js +14 -0
- package/dist/query/react/useResource.d.ts +2 -0
- package/dist/query/react/useResource.js +16 -0
- package/dist/query/types/api.d.ts +39 -0
- package/dist/query/types/cache.d.ts +51 -0
- package/dist/query/types/command.d.ts +52 -0
- package/dist/query/types/common.d.ts +65 -0
- package/dist/query/types/index.d.ts +8 -4
- package/dist/query/types/index.js +8 -5
- package/dist/query/types/plugin-hkt.d.ts +64 -0
- package/dist/query/types/resource.d.ts +49 -0
- package/dist/query/types/snapshot.d.ts +27 -0
- package/dist/query/types/snapshot.js +2 -0
- package/dist/query/types/state.d.ts +24 -0
- package/dist/signals/base/ComputeCache.js +1 -1
- package/dist/signals/base/Devtools.js +2 -6
- package/dist/signals/signals/Computed.d.ts +1 -0
- package/dist/signals/signals/Computed.js +5 -1
- package/dist/signals/signals/Effect.d.ts +0 -4
- package/dist/signals/signals/Effect.js +0 -6
- package/dist/signals/signals/LocalState.d.ts +1 -10
- package/dist/signals/signals/LocalState.js +0 -12
- package/dist/signals/signals/Signal.d.ts +2 -8
- package/dist/signals/signals/Signal.js +1 -10
- package/dist/signals/signals/State.d.ts +2 -1
- package/dist/signals/signals/State.js +9 -0
- package/dist/signals/types/SignalOptions.d.ts +0 -2
- package/dist/signals/types/normalizeSignalOptions.js +0 -3
- package/dist/signals/types/signals.types.d.ts +3 -1
- package/docs/CHANGELOG.md +48 -2
- package/docs/migrations/0.6.0.md +224 -0
- package/docs/query/README.md +52 -562
- package/docs/query/api/README.md +59 -0
- package/docs/query/api/_CacheEntry.md +39 -0
- package/docs/query/api/_CacheMap.md +30 -0
- package/docs/query/api/_QueryCacheEntry.md +81 -0
- package/docs/query/api/command-agent.md +60 -0
- package/docs/query/api/command.md +76 -0
- package/docs/query/api/resource-agent.md +68 -0
- package/docs/query/api/resource.md +77 -0
- package/docs/query/concepts/agent.md +70 -0
- package/docs/query/concepts/architecture.md +139 -0
- package/docs/query/concepts/cache.md +81 -0
- package/docs/query/concepts/dataflows.md +473 -0
- package/docs/query/concepts/keyed.md +42 -0
- package/docs/query/concepts/machine.md +106 -0
- package/docs/query/concepts/patching.md +85 -0
- package/docs/query/usage/broadcast.md +188 -0
- package/docs/query/usage/command.md +203 -0
- package/docs/query/usage/lifecycle.md +114 -0
- package/docs/query/usage/links.md +125 -0
- package/docs/query/usage/plugins.md +96 -0
- package/docs/query/usage/resource.md +206 -0
- package/docs/query/usage/snapshot.md +80 -0
- package/docs/usage/react/README.md +45 -91
- package/package.json +5 -7
- package/dist/query/SKIP_TOKEN.d.ts +0 -1
- package/dist/query/SKIP_TOKEN.js +0 -1
- package/dist/query/api/createCommand.d.ts +0 -21
- package/dist/query/api/createCommand.js +0 -20
- package/dist/query/api/createOperation.d.ts +0 -5
- package/dist/query/api/createOperation.js +0 -6
- package/dist/query/api/createResource.d.ts +0 -3
- package/dist/query/api/createResource.js +0 -2
- package/dist/query/api/createResourceDuplicator.d.ts +0 -4
- package/dist/query/api/createResourceDuplicator.js +0 -2
- package/dist/query/api/resetAllQueriesCache.d.ts +0 -1
- package/dist/query/api/resetAllQueriesCache.js +0 -4
- package/dist/query/core/Command/Command.d.ts +0 -35
- package/dist/query/core/Command/Command.js +0 -210
- package/dist/query/core/Command/CommandAgent.d.ts +0 -19
- package/dist/query/core/Command/CommandAgent.js +0 -54
- package/dist/query/core/Command/index.d.ts +0 -2
- package/dist/query/core/Command/index.js +0 -2
- package/dist/query/core/Operation/Operation.d.ts +0 -8
- package/dist/query/core/Operation/Operation.js +0 -4
- package/dist/query/core/Operation/OperationAgent.d.ts +0 -4
- package/dist/query/core/Operation/OperationAgent.js +0 -4
- package/dist/query/core/QueriesCache.d.ts +0 -9
- package/dist/query/core/QueriesCache.js +0 -28
- package/dist/query/core/QueriesLifetimeHooks.d.ts +0 -22
- package/dist/query/core/QueriesLifetimeHooks.js +0 -86
- package/dist/query/core/ResetAllQueriesSignal.d.ts +0 -6
- package/dist/query/core/ResetAllQueriesSignal.js +0 -11
- package/dist/query/core/Resource/Resource.d.ts +0 -51
- package/dist/query/core/Resource/Resource.js +0 -232
- package/dist/query/core/Resource/ResourceAgent.d.ts +0 -35
- package/dist/query/core/Resource/ResourceAgent.js +0 -110
- package/dist/query/core/Resource/ResourceDuplicator.d.ts +0 -73
- package/dist/query/core/Resource/ResourceDuplicator.js +0 -227
- package/dist/query/core/Resource/ResourceDuplicatorAgent.d.ts +0 -35
- package/dist/query/core/Resource/ResourceDuplicatorAgent.js +0 -110
- package/dist/query/core/Resource/ResourceRef.d.ts +0 -16
- package/dist/query/core/Resource/ResourceRef.js +0 -136
- package/dist/query/lib/IndirectMap.d.ts +0 -19
- package/dist/query/lib/IndirectMap.js +0 -88
- package/dist/query/lib/ReactiveCache.d.ts +0 -62
- package/dist/query/lib/ReactiveCache.js +0 -80
- package/dist/query/react/useCommandAgent.d.ts +0 -24
- package/dist/query/react/useCommandAgent.js +0 -39
- package/dist/query/react/useOperationAgent.d.ts +0 -6
- package/dist/query/react/useOperationAgent.js +0 -6
- package/dist/query/react/useResourceAgent.d.ts +0 -6
- package/dist/query/react/useResourceAgent.js +0 -31
- package/dist/query/react/useResourceRef.d.ts +0 -5
- package/dist/query/react/useResourceRef.js +0 -13
- package/dist/query/types/Command.types.d.ts +0 -154
- package/dist/query/types/Command.types.js +0 -1
- package/dist/query/types/Operation.types.d.ts +0 -13
- package/dist/query/types/Operation.types.js +0 -1
- package/dist/query/types/Resource.types.d.ts +0 -129
- package/dist/query/types/Resource.types.js +0 -1
- package/dist/query/types/shared.types.d.ts +0 -26
- package/dist/query/types/shared.types.js +0 -1
- package/dist/query-v2/api/createApi.d.ts +0 -10
- package/dist/query-v2/api/createApi.js +0 -83
- package/dist/query-v2/core/common/CacheEntry.d.ts +0 -29
- package/dist/query-v2/core/common/CacheEntry.js +0 -71
- package/dist/query-v2/core/common/CacheMap.d.ts +0 -38
- package/dist/query-v2/core/common/CacheMap.js +0 -127
- package/dist/query-v2/core/common/LifecycleHooks.d.ts +0 -22
- package/dist/query-v2/core/common/LifecycleHooks.js +0 -104
- package/dist/query-v2/core/common/index.d.ts +0 -3
- package/dist/query-v2/core/common/index.js +0 -3
- package/dist/query-v2/core/index.d.ts +0 -3
- package/dist/query-v2/core/index.js +0 -3
- package/dist/query-v2/core/machines/Machine.d.ts +0 -14
- package/dist/query-v2/core/machines/Machine.js +0 -33
- package/dist/query-v2/core/machines/MachineError.d.ts +0 -11
- package/dist/query-v2/core/machines/MachineError.js +0 -26
- package/dist/query-v2/core/machines/MachineIdle.d.ts +0 -8
- package/dist/query-v2/core/machines/MachineIdle.js +0 -19
- package/dist/query-v2/core/machines/MachinePending.d.ts +0 -12
- package/dist/query-v2/core/machines/MachinePending.js +0 -29
- package/dist/query-v2/core/machines/MachineRefreshing.d.ts +0 -14
- package/dist/query-v2/core/machines/MachineRefreshing.js +0 -46
- package/dist/query-v2/core/machines/MachineSuccess.d.ts +0 -16
- package/dist/query-v2/core/machines/MachineSuccess.js +0 -42
- package/dist/query-v2/core/machines/MachineWithData.d.ts +0 -18
- package/dist/query-v2/core/machines/MachineWithData.js +0 -40
- package/dist/query-v2/core/machines/Patcher.d.ts +0 -20
- package/dist/query-v2/core/machines/Patcher.js +0 -104
- package/dist/query-v2/core/machines/index.d.ts +0 -8
- package/dist/query-v2/core/machines/index.js +0 -8
- package/dist/query-v2/core/resource/ResourceV2.d.ts +0 -120
- package/dist/query-v2/core/resource/ResourceV2.js +0 -464
- package/dist/query-v2/core/resource/ResourceV2Agent.d.ts +0 -26
- package/dist/query-v2/core/resource/ResourceV2Agent.js +0 -132
- package/dist/query-v2/core/resource/index.d.ts +0 -2
- package/dist/query-v2/core/resource/index.js +0 -2
- package/dist/query-v2/index.d.ts +0 -11
- package/dist/query-v2/index.js +0 -17
- package/dist/query-v2/lib/NO_VALUE.d.ts +0 -2
- package/dist/query-v2/lib/NO_VALUE.js +0 -1
- package/dist/query-v2/lib/SKIP_TOKEN.d.ts +0 -2
- package/dist/query-v2/lib/SKIP_TOKEN.js +0 -1
- package/dist/query-v2/lib/index.d.ts +0 -4
- package/dist/query-v2/lib/index.js +0 -3
- package/dist/query-v2/plugins/ReactHooksPlugin.d.ts +0 -25
- package/dist/query-v2/plugins/ReactHooksPlugin.js +0 -19
- package/dist/query-v2/plugins/types.d.ts +0 -1
- package/dist/query-v2/react/__tests__/helpers.d.ts +0 -12
- package/dist/query-v2/react/__tests__/helpers.js +0 -33
- package/dist/query-v2/react/index.d.ts +0 -2
- package/dist/query-v2/react/index.js +0 -2
- package/dist/query-v2/react/useResourceV2Agent.d.ts +0 -12
- package/dist/query-v2/react/useResourceV2Agent.js +0 -36
- package/dist/query-v2/react/useResourceV2Ref.d.ts +0 -12
- package/dist/query-v2/react/useResourceV2Ref.js +0 -57
- package/dist/query-v2/snapshot/Snapshot.d.ts +0 -13
- package/dist/query-v2/snapshot/Snapshot.js +0 -76
- package/dist/query-v2/types/agent.types.d.ts +0 -54
- package/dist/query-v2/types/api.types.d.ts +0 -22
- package/dist/query-v2/types/cache.types.d.ts +0 -37
- package/dist/query-v2/types/index.d.ts +0 -9
- package/dist/query-v2/types/index.js +0 -9
- package/dist/query-v2/types/lifecycle.types.d.ts +0 -25
- package/dist/query-v2/types/machine.types.d.ts +0 -67
- package/dist/query-v2/types/plugin.types.d.ts +0 -38
- package/dist/query-v2/types/resource.types.d.ts +0 -35
- package/dist/query-v2/types/resource.types.js +0 -1
- package/dist/query-v2/types/shared.types.d.ts +0 -20
- package/dist/query-v2/types/shared.types.js +0 -1
- package/dist/query-v2/types/snapshot.types.d.ts +0 -21
- package/dist/query-v2/types/snapshot.types.js +0 -1
- package/docs/contributing/query-v2/README.md +0 -379
- package/docs/migrations/query-v2.md +0 -171
- package/docs/query-v2/README.md +0 -280
- package/docs/query-v2/api-reference.md +0 -235
- package/docs/query-v2/optimistic-updates.md +0 -148
- package/docs/query-v2/ssr.md +0 -130
- /package/dist/{query-v2 → query}/lib/stableStringify.d.ts +0 -0
- /package/dist/{query-v2/plugins/types.js → query/types/api.js} +0 -0
- /package/dist/{query-v2/types/agent.types.js → query/types/cache.js} +0 -0
- /package/dist/{query-v2/types/api.types.js → query/types/command.js} +0 -0
- /package/dist/{query-v2/types/cache.types.js → query/types/common.js} +0 -0
- /package/dist/{query-v2/types/lifecycle.types.js → query/types/plugin-hkt.js} +0 -0
- /package/dist/{query-v2/types/machine.types.js → query/types/resource.js} +0 -0
- /package/dist/{query-v2/types/plugin.types.js → query/types/state.js} +0 -0
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { Computed, Signal } from "../../../signals";
|
|
2
|
-
export class ResourceAgent {
|
|
3
|
-
_resource;
|
|
4
|
-
_resources$ = Signal.state({
|
|
5
|
-
previous$: null,
|
|
6
|
-
current$: null,
|
|
7
|
-
}, { isDisabled: true });
|
|
8
|
-
state$ = Computed.create(() => {
|
|
9
|
-
const resources = this._resources$.get();
|
|
10
|
-
let prevState;
|
|
11
|
-
const currState = resources.current$?.value$.get();
|
|
12
|
-
// Отлавливаем кейс, когда ресурс был спрошен.
|
|
13
|
-
// На данные момент единсвенная причина сброса - resetAllQueriesCache(),
|
|
14
|
-
// но в будущем могут быть и другие причины, что потребует доработку.
|
|
15
|
-
if (currState && !currState.isInitiated) {
|
|
16
|
-
this._resource.initiate(currState.args, { cache: resources.current$ });
|
|
17
|
-
return {
|
|
18
|
-
isInitiated: true,
|
|
19
|
-
isLoading: true,
|
|
20
|
-
isInitialLoading: true,
|
|
21
|
-
isDone: false,
|
|
22
|
-
isSuccess: false,
|
|
23
|
-
isError: false,
|
|
24
|
-
isReloading: false,
|
|
25
|
-
error: undefined,
|
|
26
|
-
data: undefined,
|
|
27
|
-
// TODO вообще нет точного представлния, как блокировака доложна работать.
|
|
28
|
-
// Мб тут стоит брать currState.isLocked.
|
|
29
|
-
isLocked: false,
|
|
30
|
-
args: currState.args,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
if (!currState?.isDone) {
|
|
34
|
-
prevState = resources.previous$?.value;
|
|
35
|
-
}
|
|
36
|
-
// Нет текущего состояния — дефолт
|
|
37
|
-
if (!currState) {
|
|
38
|
-
return {
|
|
39
|
-
isInitiated: false,
|
|
40
|
-
isLoading: false,
|
|
41
|
-
isInitialLoading: false,
|
|
42
|
-
isDone: false,
|
|
43
|
-
isSuccess: false,
|
|
44
|
-
isError: false,
|
|
45
|
-
isLocked: false,
|
|
46
|
-
isReloading: false,
|
|
47
|
-
error: undefined,
|
|
48
|
-
data: undefined,
|
|
49
|
-
args: undefined,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
// Если идёт загрузка, но есть успешные данные из прошлого запроса — показываем их
|
|
53
|
-
const isShowPrev = currState.isLoading && prevState && prevState.isSuccess;
|
|
54
|
-
return {
|
|
55
|
-
isInitiated: currState.isInitiated || !!prevState,
|
|
56
|
-
isLoading: currState.isLoading,
|
|
57
|
-
isInitialLoading: currState.isLoading && !currState.isDone && !prevState?.isDone,
|
|
58
|
-
isDone: currState.isDone,
|
|
59
|
-
isSuccess: currState.isSuccess,
|
|
60
|
-
isError: currState.isError,
|
|
61
|
-
isLocked: currState.isLocked,
|
|
62
|
-
isReloading: currState.isReloading,
|
|
63
|
-
error: isShowPrev ? (prevState.error ?? undefined) : (currState.error ?? undefined),
|
|
64
|
-
data: isShowPrev ? (prevState.data ?? undefined) : (currState.data ?? undefined),
|
|
65
|
-
args: currState.args ?? undefined,
|
|
66
|
-
};
|
|
67
|
-
}, { isDisabled: true });
|
|
68
|
-
constructor(_resource) {
|
|
69
|
-
this._resource = _resource;
|
|
70
|
-
}
|
|
71
|
-
initiate(args, force = false) {
|
|
72
|
-
const current = this._resources$.peek().current$;
|
|
73
|
-
const cache = this._resource.getQueryCache(args);
|
|
74
|
-
if (!cache) {
|
|
75
|
-
const newCache = this._resource.initiate(args);
|
|
76
|
-
this._next(newCache);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (force || !(cache.value.isDone || cache.value.isLoading)) {
|
|
80
|
-
this._resource.initiate(args, { cache });
|
|
81
|
-
}
|
|
82
|
-
if (current !== cache) {
|
|
83
|
-
this._next(cache);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
compareArgs(args, otherArgs) {
|
|
87
|
-
return this._resource.compareArgs(args, otherArgs);
|
|
88
|
-
}
|
|
89
|
-
_next(newCache) {
|
|
90
|
-
const { previous$, current$ } = this._resources$.peek();
|
|
91
|
-
if (!current$) {
|
|
92
|
-
this._resources$.set({
|
|
93
|
-
previous$: null,
|
|
94
|
-
current$: newCache,
|
|
95
|
-
});
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
if (!current$.value$.peek().isDone && previous$?.value$.peek().isDone) {
|
|
99
|
-
this._resources$.set({
|
|
100
|
-
previous$: previous$,
|
|
101
|
-
current$: newCache,
|
|
102
|
-
});
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
this._resources$.set({
|
|
106
|
-
previous$: current$,
|
|
107
|
-
current$: newCache,
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { Observable, Subject } from "rxjs";
|
|
2
|
-
import { ResourceDefinition } from "../../../query/types";
|
|
3
|
-
import { ReadableSignalLike } from "../../../signals/types";
|
|
4
|
-
import { CoreResourceQueryState, Resource } from "./Resource";
|
|
5
|
-
import { ResourceDuplicatorAgent } from "./ResourceDuplicatorAgent";
|
|
6
|
-
export type DuplicatorOptions<D extends DuplicatorDefinition> = {
|
|
7
|
-
resource: Resource<D["RESOURCE_DEFINITION"]>;
|
|
8
|
-
getArgKey: (item: D["ARGS_ITEM"]) => string | number;
|
|
9
|
-
getDataKey: (item: D["DATA_ITEM"]) => string | number;
|
|
10
|
-
cacheLifetime?: number | false;
|
|
11
|
-
};
|
|
12
|
-
export type DuplicatorDefinition<D extends ResourceDefinition = ResourceDefinition> = {
|
|
13
|
-
ARGS_ITEM: D["Args"] extends Array<any> ? D["Args"][number] : never;
|
|
14
|
-
DATA_ITEM: D["Data"] extends Array<any> ? D["Data"][number] : never;
|
|
15
|
-
RESOURCE_DEFINITION: D;
|
|
16
|
-
};
|
|
17
|
-
type State<D extends DuplicatorDefinition> = CoreResourceQueryState<D["RESOURCE_DEFINITION"]> & {
|
|
18
|
-
unreleasedArgs?: D["ARGS_ITEM"][];
|
|
19
|
-
};
|
|
20
|
-
type Cache<D extends DuplicatorDefinition> = ComputedReactiveCache<State<D>>;
|
|
21
|
-
export type CoreResourceDuplicatorCache<D extends DuplicatorDefinition> = Cache<D>;
|
|
22
|
-
export declare class ResourceDuplicator<D extends DuplicatorDefinition> {
|
|
23
|
-
private _options;
|
|
24
|
-
private _fis;
|
|
25
|
-
private _caches;
|
|
26
|
-
private get _resource();
|
|
27
|
-
constructor(_options: DuplicatorOptions<D>);
|
|
28
|
-
getQueryCache(args: D["ARGS_ITEM"][]): Cache<D> | undefined;
|
|
29
|
-
createCache(args: D["ARGS_ITEM"][]): Cache<D>;
|
|
30
|
-
initiate(args: D["ARGS_ITEM"][], cache?: Cache<D>): Cache<D>;
|
|
31
|
-
serialize(args: D["ARGS_ITEM"][]): string;
|
|
32
|
-
compareArgs(a: D["ARGS_ITEM"][], b: D["ARGS_ITEM"][]): boolean;
|
|
33
|
-
createAgent: () => ResourceDuplicatorAgent<D>;
|
|
34
|
-
/** @deprecated */
|
|
35
|
-
d_init(args: D["ARGS_ITEM"][]): {
|
|
36
|
-
value$: import("../../../signals").ComputeFn<State<D>>;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
export declare class ComputedReactiveCache<T> {
|
|
40
|
-
/**
|
|
41
|
-
* Реактивное значене (Observable)
|
|
42
|
-
*/
|
|
43
|
-
value$: ReadableSignalLike<T>;
|
|
44
|
-
/**
|
|
45
|
-
* Значение без сайд-эффектов (для использования в DevTools)
|
|
46
|
-
*/
|
|
47
|
-
spy$: Observable<T>;
|
|
48
|
-
/**
|
|
49
|
-
* Subject, уведомляющий об очистке кэша.
|
|
50
|
-
*/
|
|
51
|
-
onClean$: Subject<T>;
|
|
52
|
-
closed: boolean;
|
|
53
|
-
private _getValue;
|
|
54
|
-
/**
|
|
55
|
-
* Создает новый экземпляр `ReactiveCacheItem`.
|
|
56
|
-
*
|
|
57
|
-
* @param options Параметры для настройки элемента кэша.
|
|
58
|
-
* @param options.initialState Начальное состояние кэша.
|
|
59
|
-
* @param options.cacheLifeTime Время жизни кэша в миллисекундах (по умолчанию 60_000).
|
|
60
|
-
*/
|
|
61
|
-
constructor(options: {
|
|
62
|
-
obs: Observable<T>;
|
|
63
|
-
getValue: () => T;
|
|
64
|
-
cacheLifeTime: number | false;
|
|
65
|
-
});
|
|
66
|
-
private _getOnRefCountZero;
|
|
67
|
-
get value(): T;
|
|
68
|
-
/**
|
|
69
|
-
* Завершает работу кэша, закрывая все потоки и уведомляя об очистке.
|
|
70
|
-
*/
|
|
71
|
-
complete(): void;
|
|
72
|
-
}
|
|
73
|
-
export {};
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { finalize, ReplaySubject, share, Subject, takeUntil, timer } from "rxjs";
|
|
2
|
-
import { Signal, signalize } from "../../../signals";
|
|
3
|
-
import { ResourceDuplicatorAgent } from "./ResourceDuplicatorAgent";
|
|
4
|
-
export class ResourceDuplicator {
|
|
5
|
-
_options;
|
|
6
|
-
_fis = new Map();
|
|
7
|
-
_caches;
|
|
8
|
-
get _resource() {
|
|
9
|
-
return this._options.resource;
|
|
10
|
-
}
|
|
11
|
-
constructor(_options) {
|
|
12
|
-
this._options = _options;
|
|
13
|
-
this._caches = new Map();
|
|
14
|
-
}
|
|
15
|
-
getQueryCache(args) {
|
|
16
|
-
const key = this.serialize(args);
|
|
17
|
-
return this._caches.get(key);
|
|
18
|
-
}
|
|
19
|
-
createCache(args) {
|
|
20
|
-
const key = this.serialize(args);
|
|
21
|
-
const { value$ } = this.d_init(args);
|
|
22
|
-
const cache = new ComputedReactiveCache({
|
|
23
|
-
cacheLifeTime: this._options.cacheLifetime ?? 60_000,
|
|
24
|
-
getValue: () => value$.get(),
|
|
25
|
-
obs: value$.obs,
|
|
26
|
-
});
|
|
27
|
-
cache.onClean$.subscribe(() => {
|
|
28
|
-
args.forEach((arg) => {
|
|
29
|
-
const argKey = this._options.getArgKey(arg);
|
|
30
|
-
const fi = this._fis.get(argKey);
|
|
31
|
-
if (!fi)
|
|
32
|
-
return;
|
|
33
|
-
fi.k--;
|
|
34
|
-
if (fi.k <= 0) {
|
|
35
|
-
this._fis.delete(argKey);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
this._caches.delete(key);
|
|
39
|
-
});
|
|
40
|
-
this._caches.set(key, cache);
|
|
41
|
-
return cache;
|
|
42
|
-
}
|
|
43
|
-
initiate(args, cache) {
|
|
44
|
-
const cacheInstance = cache ?? this.getQueryCache(args) ?? this.createCache(args);
|
|
45
|
-
const unreleasedArgs = cacheInstance.value.unreleasedArgs;
|
|
46
|
-
if (unreleasedArgs && unreleasedArgs.length !== 0) {
|
|
47
|
-
this._resource.initiate(unreleasedArgs);
|
|
48
|
-
}
|
|
49
|
-
const uninitiatedCaches = new Set();
|
|
50
|
-
args.forEach((arg) => {
|
|
51
|
-
const argKey = this._options.getArgKey(arg);
|
|
52
|
-
const fi = this._fis.get(argKey);
|
|
53
|
-
if (fi && !fi.cache.value.isInitiated) {
|
|
54
|
-
uninitiatedCaches.add(fi.cache);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
uninitiatedCaches.forEach((c) => {
|
|
58
|
-
this._resource.initiate(c.value.args, { cache: c });
|
|
59
|
-
});
|
|
60
|
-
return cacheInstance;
|
|
61
|
-
}
|
|
62
|
-
serialize(args) {
|
|
63
|
-
if (!args)
|
|
64
|
-
return "";
|
|
65
|
-
const argsKeys = args.map((a) => this._options.getArgKey(a));
|
|
66
|
-
return argsKeys.join("|");
|
|
67
|
-
}
|
|
68
|
-
compareArgs(a, b) {
|
|
69
|
-
return this.serialize(a) === this.serialize(b);
|
|
70
|
-
}
|
|
71
|
-
createAgent = () => {
|
|
72
|
-
return new ResourceDuplicatorAgent(this);
|
|
73
|
-
};
|
|
74
|
-
/** @deprecated */
|
|
75
|
-
d_init(args) {
|
|
76
|
-
const argsKeys = args.map((a) => this._options.getArgKey(a));
|
|
77
|
-
const releasedCaches = new Set();
|
|
78
|
-
const unreleasedArgs = [];
|
|
79
|
-
args.forEach((arg) => {
|
|
80
|
-
const argKey = this._options.getArgKey(arg);
|
|
81
|
-
const fi = this._fis.get(argKey);
|
|
82
|
-
if (!fi || !fi.cache.value.isInitiated) {
|
|
83
|
-
unreleasedArgs.push(arg);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
fi.k++;
|
|
87
|
-
releasedCaches.add(fi.cache);
|
|
88
|
-
});
|
|
89
|
-
const queryCache = unreleasedArgs?.length > 0 ? this._resource.createQueryCache(unreleasedArgs) : null;
|
|
90
|
-
unreleasedArgs.forEach((arg) => {
|
|
91
|
-
const argKey = this._options.getArgKey(arg);
|
|
92
|
-
let fi = this._fis.get(argKey);
|
|
93
|
-
if (!fi) {
|
|
94
|
-
fi = {
|
|
95
|
-
k: 1,
|
|
96
|
-
cache: queryCache,
|
|
97
|
-
};
|
|
98
|
-
this._fis.set(argKey, fi);
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
return {
|
|
102
|
-
value$: Signal.compute(() => {
|
|
103
|
-
const itemsAcc = [];
|
|
104
|
-
if (queryCache) {
|
|
105
|
-
itemsAcc.push(queryCache.value$.get());
|
|
106
|
-
}
|
|
107
|
-
for (const rc of releasedCaches) {
|
|
108
|
-
itemsAcc.push(rc.value$.get());
|
|
109
|
-
}
|
|
110
|
-
const isNotInitiated = itemsAcc.some((i) => !i.isInitiated);
|
|
111
|
-
const baseReturn = {
|
|
112
|
-
transactions: null,
|
|
113
|
-
abortController: null,
|
|
114
|
-
args,
|
|
115
|
-
savedData: null,
|
|
116
|
-
data: null,
|
|
117
|
-
error: null,
|
|
118
|
-
isError: false,
|
|
119
|
-
isLoading: false,
|
|
120
|
-
isReloading: false,
|
|
121
|
-
isDone: false,
|
|
122
|
-
isSuccess: false,
|
|
123
|
-
isLocked: false,
|
|
124
|
-
isInitiated: true,
|
|
125
|
-
lockCount: 0,
|
|
126
|
-
unreleasedArgs,
|
|
127
|
-
};
|
|
128
|
-
if (isNotInitiated)
|
|
129
|
-
return {
|
|
130
|
-
...baseReturn,
|
|
131
|
-
isInitiated: false,
|
|
132
|
-
};
|
|
133
|
-
const isError = itemsAcc.some((i) => i.isError);
|
|
134
|
-
if (isError) {
|
|
135
|
-
const firstError = itemsAcc.find((i) => i.isError);
|
|
136
|
-
return {
|
|
137
|
-
...baseReturn,
|
|
138
|
-
isError: true,
|
|
139
|
-
isDone: true,
|
|
140
|
-
error: firstError.error,
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
const isLoading = itemsAcc.some((i) => i.isLoading);
|
|
144
|
-
if (isLoading)
|
|
145
|
-
return {
|
|
146
|
-
...baseReturn,
|
|
147
|
-
isLoading: true,
|
|
148
|
-
};
|
|
149
|
-
const dataAcc = [];
|
|
150
|
-
itemsAcc.forEach((item) => {
|
|
151
|
-
item.data?.forEach((d) => {
|
|
152
|
-
const dataKey = this._options.getDataKey(d);
|
|
153
|
-
const index = argsKeys.findIndex((ak) => ak === dataKey);
|
|
154
|
-
if (index === -1)
|
|
155
|
-
return;
|
|
156
|
-
dataAcc[index] = d;
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
return {
|
|
160
|
-
...baseReturn,
|
|
161
|
-
isSuccess: true,
|
|
162
|
-
isDone: true,
|
|
163
|
-
data: dataAcc,
|
|
164
|
-
};
|
|
165
|
-
}, { isDisabled: true }),
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
export class ComputedReactiveCache {
|
|
170
|
-
/**
|
|
171
|
-
* Реактивное значене (Observable)
|
|
172
|
-
*/
|
|
173
|
-
value$;
|
|
174
|
-
/**
|
|
175
|
-
* Значение без сайд-эффектов (для использования в DevTools)
|
|
176
|
-
*/
|
|
177
|
-
spy$;
|
|
178
|
-
/**
|
|
179
|
-
* Subject, уведомляющий об очистке кэша.
|
|
180
|
-
*/
|
|
181
|
-
onClean$ = new Subject();
|
|
182
|
-
closed = false;
|
|
183
|
-
_getValue;
|
|
184
|
-
/**
|
|
185
|
-
* Создает новый экземпляр `ReactiveCacheItem`.
|
|
186
|
-
*
|
|
187
|
-
* @param options Параметры для настройки элемента кэша.
|
|
188
|
-
* @param options.initialState Начальное состояние кэша.
|
|
189
|
-
* @param options.cacheLifeTime Время жизни кэша в миллисекундах (по умолчанию 60_000).
|
|
190
|
-
*/
|
|
191
|
-
constructor(options) {
|
|
192
|
-
const cacheLifeTime = options.cacheLifeTime ?? 60_000;
|
|
193
|
-
this.spy$ = options.obs.pipe(takeUntil(this.onClean$));
|
|
194
|
-
this.value$ = signalize(options.obs.pipe(finalize(() => {
|
|
195
|
-
this.complete();
|
|
196
|
-
}), share({
|
|
197
|
-
connector: () => new ReplaySubject(1),
|
|
198
|
-
resetOnRefCountZero: this._getOnRefCountZero(cacheLifeTime),
|
|
199
|
-
resetOnComplete: true,
|
|
200
|
-
})));
|
|
201
|
-
this._getValue = options.getValue;
|
|
202
|
-
}
|
|
203
|
-
_getOnRefCountZero(cacheLifeTime) {
|
|
204
|
-
if (cacheLifeTime === false) {
|
|
205
|
-
return false;
|
|
206
|
-
}
|
|
207
|
-
if (cacheLifeTime <= 0) {
|
|
208
|
-
return true;
|
|
209
|
-
}
|
|
210
|
-
return () => {
|
|
211
|
-
return timer(cacheLifeTime);
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
get value() {
|
|
215
|
-
return this._getValue();
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Завершает работу кэша, закрывая все потоки и уведомляя об очистке.
|
|
219
|
-
*/
|
|
220
|
-
complete() {
|
|
221
|
-
if (this.closed)
|
|
222
|
-
return;
|
|
223
|
-
this.closed = true;
|
|
224
|
-
this.onClean$.next(this._getValue());
|
|
225
|
-
this.onClean$.complete();
|
|
226
|
-
}
|
|
227
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { DuplicatorDefinition, ResourceDuplicator } from "../../../query/core/Resource/ResourceDuplicator";
|
|
2
|
-
import { ResourceAgentInstance } from "../../../query/types";
|
|
3
|
-
export declare class ResourceDuplicatorAgent<D extends DuplicatorDefinition> implements ResourceAgentInstance<D["RESOURCE_DEFINITION"]> {
|
|
4
|
-
private _resource;
|
|
5
|
-
private _resources$;
|
|
6
|
-
state$: import("../../../signals").ComputeFn<{
|
|
7
|
-
isInitiated: boolean;
|
|
8
|
-
isLoading: boolean;
|
|
9
|
-
isInitialLoading: boolean;
|
|
10
|
-
isDone: boolean;
|
|
11
|
-
isSuccess: boolean;
|
|
12
|
-
isError: boolean;
|
|
13
|
-
isLocked: boolean;
|
|
14
|
-
isReloading: boolean;
|
|
15
|
-
error: undefined;
|
|
16
|
-
data: undefined;
|
|
17
|
-
args: D["ARGS_ITEM"][];
|
|
18
|
-
} | {
|
|
19
|
-
isInitiated: boolean;
|
|
20
|
-
isLoading: boolean;
|
|
21
|
-
isInitialLoading: boolean;
|
|
22
|
-
isDone: boolean;
|
|
23
|
-
isSuccess: boolean;
|
|
24
|
-
isError: boolean;
|
|
25
|
-
isLocked: boolean;
|
|
26
|
-
isReloading: boolean;
|
|
27
|
-
error: {} | undefined;
|
|
28
|
-
data: NonNullable<D["RESOURCE_DEFINITION"]["Data"]> | undefined;
|
|
29
|
-
args: NonNullable<D["RESOURCE_DEFINITION"]["Args"]> | undefined;
|
|
30
|
-
}>;
|
|
31
|
-
constructor(_resource: ResourceDuplicator<D>);
|
|
32
|
-
initiate(args: D["ARGS_ITEM"][], force?: boolean): void;
|
|
33
|
-
compareArgs(args: D["ARGS_ITEM"][], otherArgs: D["ARGS_ITEM"][]): boolean;
|
|
34
|
-
private _next;
|
|
35
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { Computed, Signal } from "../../../signals";
|
|
2
|
-
export class ResourceDuplicatorAgent {
|
|
3
|
-
_resource;
|
|
4
|
-
_resources$ = Signal.state({
|
|
5
|
-
previous$: null,
|
|
6
|
-
current$: null,
|
|
7
|
-
}, { isDisabled: true });
|
|
8
|
-
state$ = Computed.create(() => {
|
|
9
|
-
const resources = this._resources$.get();
|
|
10
|
-
let prevState;
|
|
11
|
-
const currState = resources.current$?.value$.get();
|
|
12
|
-
// Отлавливаем кейс, когда ресурс был спрошен.
|
|
13
|
-
// На данные момент единсвенная причина сброса - resetAllQueriesCache(),
|
|
14
|
-
// но в будущем могут быть и другие причины, что потребует доработку.
|
|
15
|
-
if (currState && !currState.isInitiated) {
|
|
16
|
-
this._resource.initiate(currState.args, resources.current$);
|
|
17
|
-
return {
|
|
18
|
-
isInitiated: true,
|
|
19
|
-
isLoading: true,
|
|
20
|
-
isInitialLoading: true,
|
|
21
|
-
isDone: false,
|
|
22
|
-
isSuccess: false,
|
|
23
|
-
isError: false,
|
|
24
|
-
isReloading: false,
|
|
25
|
-
error: undefined,
|
|
26
|
-
data: undefined,
|
|
27
|
-
// TODO вообще нет точного представлния, как блокировака доложна работать.
|
|
28
|
-
// Мб тут стоит брать currState.isLocked.
|
|
29
|
-
isLocked: false,
|
|
30
|
-
args: currState.args,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
if (!currState?.isDone) {
|
|
34
|
-
prevState = resources.previous$?.value;
|
|
35
|
-
}
|
|
36
|
-
// Нет текущего состояния — дефолт
|
|
37
|
-
if (!currState) {
|
|
38
|
-
return {
|
|
39
|
-
isInitiated: false,
|
|
40
|
-
isLoading: false,
|
|
41
|
-
isInitialLoading: false,
|
|
42
|
-
isDone: false,
|
|
43
|
-
isSuccess: false,
|
|
44
|
-
isError: false,
|
|
45
|
-
isLocked: false,
|
|
46
|
-
isReloading: false,
|
|
47
|
-
error: undefined,
|
|
48
|
-
data: undefined,
|
|
49
|
-
args: undefined,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
// Если идёт загрузка, но есть успешные данные из прошлого запроса — показываем их
|
|
53
|
-
const isShowPrev = currState.isLoading && prevState && prevState.isSuccess;
|
|
54
|
-
return {
|
|
55
|
-
isInitiated: currState.isInitiated || !!prevState,
|
|
56
|
-
isLoading: currState.isLoading,
|
|
57
|
-
isInitialLoading: currState.isLoading && !currState.isDone && !prevState?.isDone,
|
|
58
|
-
isDone: currState.isDone,
|
|
59
|
-
isSuccess: currState.isSuccess,
|
|
60
|
-
isError: currState.isError,
|
|
61
|
-
isLocked: currState.isLocked,
|
|
62
|
-
isReloading: currState.isReloading,
|
|
63
|
-
error: isShowPrev ? (prevState.error ?? undefined) : (currState.error ?? undefined),
|
|
64
|
-
data: isShowPrev ? (prevState.data ?? undefined) : (currState.data ?? undefined),
|
|
65
|
-
args: currState.args ?? undefined,
|
|
66
|
-
};
|
|
67
|
-
}, { isDisabled: true });
|
|
68
|
-
constructor(_resource) {
|
|
69
|
-
this._resource = _resource;
|
|
70
|
-
}
|
|
71
|
-
initiate(args, force = false) {
|
|
72
|
-
const current = this._resources$.peek().current$;
|
|
73
|
-
const cache = this._resource.getQueryCache(args);
|
|
74
|
-
if (!cache) {
|
|
75
|
-
const newCache = this._resource.initiate(args);
|
|
76
|
-
this._next(newCache);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (force || !(cache.value.isDone || cache.value.isLoading)) {
|
|
80
|
-
this._resource.initiate(args, cache);
|
|
81
|
-
}
|
|
82
|
-
if (current !== cache) {
|
|
83
|
-
this._next(cache);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
compareArgs(args, otherArgs) {
|
|
87
|
-
return this._resource.compareArgs(args, otherArgs);
|
|
88
|
-
}
|
|
89
|
-
_next(newCache) {
|
|
90
|
-
const { previous$, current$ } = this._resources$.peek();
|
|
91
|
-
if (!current$) {
|
|
92
|
-
this._resources$.set({
|
|
93
|
-
previous$: null,
|
|
94
|
-
current$: newCache,
|
|
95
|
-
});
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
if (!current$.value$.peek().isDone && previous$?.value$.peek().isDone) {
|
|
99
|
-
this._resources$.set({
|
|
100
|
-
previous$: previous$,
|
|
101
|
-
current$: newCache,
|
|
102
|
-
});
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
this._resources$.set({
|
|
106
|
-
previous$: current$,
|
|
107
|
-
current$: newCache,
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ResourceDefinition, ResourceRefInstance, ResourceTransaction } from "../../../query/types";
|
|
2
|
-
import { Resource } from "./Resource";
|
|
3
|
-
export declare class ResourceRef<D extends ResourceDefinition> implements ResourceRefInstance<D> {
|
|
4
|
-
private readonly _resource;
|
|
5
|
-
private readonly _args;
|
|
6
|
-
private _cacheItem;
|
|
7
|
-
constructor(_resource: Resource<D>, _args: D["Args"]);
|
|
8
|
-
get has(): boolean;
|
|
9
|
-
lock(): {
|
|
10
|
-
unlock: () => void;
|
|
11
|
-
};
|
|
12
|
-
unlockOne(): void;
|
|
13
|
-
patch(patchFn: (data: D["Data"]) => void): ResourceTransaction | null;
|
|
14
|
-
create(data: D["Data"]): void;
|
|
15
|
-
invalidate(): void;
|
|
16
|
-
}
|