@livestore/react 0.3.0-dev.17 → 0.3.0-dev.19
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/dist/.tsbuildinfo +1 -1
- package/dist/LiveStoreProvider.d.ts +2 -2
- package/dist/LiveStoreProvider.d.ts.map +1 -1
- package/dist/LiveStoreProvider.js +8 -8
- package/dist/LiveStoreProvider.js.map +1 -1
- package/dist/LiveStoreProvider.test.js +1 -1
- package/dist/LiveStoreProvider.test.js.map +1 -1
- package/package.json +5 -5
- package/src/LiveStoreProvider.test.tsx +1 -1
- package/src/LiveStoreProvider.tsx +37 -14
- package/tmp/pack.tgz +0 -0
|
@@ -2,7 +2,7 @@ import type { Adapter, BootStatus, IntentionalShutdownCause, MigrationsReport }
|
|
|
2
2
|
import { UnexpectedError } from '@livestore/common';
|
|
3
3
|
import type { LiveStoreSchema } from '@livestore/common/schema';
|
|
4
4
|
import type { BaseGraphQLContext, GraphQLOptions, OtelOptions, Store } from '@livestore/livestore';
|
|
5
|
-
import {
|
|
5
|
+
import { StoreInterrupted } from '@livestore/livestore';
|
|
6
6
|
import type { OtelTracer } from '@livestore/utils/effect';
|
|
7
7
|
import { Effect } from '@livestore/utils/effect';
|
|
8
8
|
import type * as otel from '@opentelemetry/api';
|
|
@@ -29,7 +29,7 @@ interface LiveStoreProviderProps<GraphQLContext extends BaseGraphQLContext> {
|
|
|
29
29
|
otelOptions?: Partial<OtelOptions>;
|
|
30
30
|
renderLoading: (status: BootStatus) => ReactElement;
|
|
31
31
|
renderError?: (error: UnexpectedError | unknown) => ReactElement;
|
|
32
|
-
renderShutdown?: (cause: IntentionalShutdownCause |
|
|
32
|
+
renderShutdown?: (cause: IntentionalShutdownCause | StoreInterrupted) => ReactElement;
|
|
33
33
|
adapter: Adapter;
|
|
34
34
|
/**
|
|
35
35
|
* In order for LiveStore to apply multiple mutations in a single render,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LiveStoreProvider.d.ts","sourceRoot":"","sources":["../src/LiveStoreProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACxG,OAAO,EAAe,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,KAAK,EACV,kBAAkB,EAElB,cAAc,EAEd,WAAW,EAEX,KAAK,EACN,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAe,
|
|
1
|
+
{"version":3,"file":"LiveStoreProvider.d.ts","sourceRoot":"","sources":["../src/LiveStoreProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACxG,OAAO,EAAe,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,KAAK,EACV,kBAAkB,EAElB,cAAc,EAEd,WAAW,EAEX,KAAK,EACN,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAe,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAEpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAGL,MAAM,EAQP,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,UAAU,sBAAsB,CAAC,cAAc,SAAS,kBAAkB;IACxE,MAAM,EAAE,eAAe,CAAA;IACvB;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,CACL,KAAK,EAAE,KAAK,CAAC,cAAc,EAAE,eAAe,CAAC,EAC7C,GAAG,EAAE;QAAE,gBAAgB,EAAE,gBAAgB,CAAC;QAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAA;KAAE,KAC/D,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,UAAU,CAAC,CAAA;IAC/E,cAAc,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAA;IAC/C,WAAW,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IAClC,aAAa,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,YAAY,CAAA;IACnD,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,KAAK,YAAY,CAAA;IAChE,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,wBAAwB,GAAG,gBAAgB,KAAK,YAAY,CAAA;IACrF,OAAO,EAAE,OAAO,CAAA;IAChB;;;;;;;;;;;OAWG;IACH,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,IAAI,KAAK,IAAI,CAAA;IACvC,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAoBD,eAAO,MAAM,iBAAiB,GAAI,cAAc,SAAS,kBAAkB,EAAE,+JAc1E,sBAAsB,CAAC,cAAc,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,KAAG,KAAK,CAAC,YAgC5E,CAAA"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { provideOtel, UnexpectedError } from '@livestore/common';
|
|
2
|
-
import { createStore,
|
|
2
|
+
import { createStore, StoreInterrupted } from '@livestore/livestore';
|
|
3
3
|
import { errorToString, LS_DEV } from '@livestore/utils';
|
|
4
|
-
import { Deferred, Effect, Exit, identity, Logger, LogLevel, Schema, Scope, TaskTracing } from '@livestore/utils/effect';
|
|
4
|
+
import { Cause, Deferred, Effect, Exit, identity, Logger, LogLevel, Schema, Scope, TaskTracing, } from '@livestore/utils/effect';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { LiveStoreContext } from './LiveStoreContext.js';
|
|
7
7
|
const defaultRenderError = (error) => (React.createElement(React.Fragment, null, Schema.is(UnexpectedError)(error) ? error.toString() : errorToString(error)));
|
|
8
8
|
const defaultRenderShutdown = (cause) => {
|
|
9
|
-
const reason = cause._tag === 'LiveStore.
|
|
10
|
-
?
|
|
9
|
+
const reason = cause._tag === 'LiveStore.StoreInterrupted'
|
|
10
|
+
? `interrupted due to: ${cause.reason}`
|
|
11
11
|
: cause.reason === 'devtools-import'
|
|
12
12
|
? 'devtools import'
|
|
13
13
|
: cause.reason === 'devtools-reset'
|
|
@@ -99,7 +99,7 @@ const useCreateStore = ({ schema, storeId, graphQLOptions, otelOptions, boot, ad
|
|
|
99
99
|
signal,
|
|
100
100
|
};
|
|
101
101
|
if (ctxValueRef.current.componentScope !== undefined && ctxValueRef.current.shutdownDeferred !== undefined) {
|
|
102
|
-
interrupt(ctxValueRef.current.componentScope, ctxValueRef.current.shutdownDeferred, new StoreInterrupted());
|
|
102
|
+
interrupt(ctxValueRef.current.componentScope, ctxValueRef.current.shutdownDeferred, new StoreInterrupted({ reason: 're-rendering due to changed input props' }));
|
|
103
103
|
ctxValueRef.current.componentScope = undefined;
|
|
104
104
|
ctxValueRef.current.shutdownDeferred = undefined;
|
|
105
105
|
}
|
|
@@ -122,7 +122,7 @@ const useCreateStore = ({ schema, storeId, graphQLOptions, otelOptions, boot, ad
|
|
|
122
122
|
if (ctxValueRef.current.componentScope !== undefined &&
|
|
123
123
|
ctxValueRef.current.shutdownDeferred !== undefined &&
|
|
124
124
|
ctxValueRef.current.counter === counter) {
|
|
125
|
-
interrupt(ctxValueRef.current.componentScope, ctxValueRef.current.shutdownDeferred, new
|
|
125
|
+
interrupt(ctxValueRef.current.componentScope, ctxValueRef.current.shutdownDeferred, new StoreInterrupted({ reason: 'Aborted via provided AbortController' }));
|
|
126
126
|
ctxValueRef.current.componentScope = undefined;
|
|
127
127
|
ctxValueRef.current.shutdownDeferred = undefined;
|
|
128
128
|
}
|
|
@@ -152,7 +152,7 @@ const useCreateStore = ({ schema, storeId, graphQLOptions, otelOptions, boot, ad
|
|
|
152
152
|
setContextValue({ stage: 'running', store });
|
|
153
153
|
}).pipe(Scope.extend(componentScope), Effect.forkIn(componentScope));
|
|
154
154
|
const shutdownContext = (cause) => Effect.sync(() => setContextValue({ stage: 'shutdown', cause }));
|
|
155
|
-
yield* Deferred.await(shutdownDeferred).pipe(Effect.tapErrorCause((cause) => Effect.logDebug('[@livestore/livestore/react] shutdown', cause)), Effect.catchTag('LiveStore.IntentionalShutdownCause', (cause) => shutdownContext(cause)), Effect.catchTag('LiveStore.
|
|
155
|
+
yield* Deferred.await(shutdownDeferred).pipe(Effect.tapErrorCause((cause) => Effect.logDebug('[@livestore/livestore/react] shutdown', Cause.pretty(cause))), Effect.catchTag('LiveStore.IntentionalShutdownCause', (cause) => shutdownContext(cause)), Effect.catchTag('LiveStore.StoreInterrupted', (cause) => shutdownContext(cause)), Effect.tapError((error) => Effect.sync(() => setContextValue({ stage: 'error', error }))), Effect.tapDefect((defect) => Effect.sync(() => setContextValue({ stage: 'error', error: defect }))), Effect.exit);
|
|
156
156
|
}).pipe(Effect.scoped,
|
|
157
157
|
// NOTE we're running the code above in a semaphore to make sure a previous store is always fully
|
|
158
158
|
// shutdown before a new one is created - especially when shutdown logic is async. You can't trust `React.useEffect`.
|
|
@@ -160,7 +160,7 @@ const useCreateStore = ({ schema, storeId, graphQLOptions, otelOptions, boot, ad
|
|
|
160
160
|
withSemaphore(storeId), Effect.withSpan('@livestore/react:useCreateStore'), LS_DEV ? TaskTracing.withAsyncTaggingTracing((name) => console.createTask(name)) : identity, provideOtel({ parentSpanContext: otelOptions?.rootSpanContext, otelTracer: otelOptions?.tracer }), Effect.tapCauseLogPretty, Effect.annotateLogs({ thread: 'window' }), Effect.provide(Logger.prettyWithThread('window')), Logger.withMinimumLogLevel(LogLevel.Debug), Effect.runFork);
|
|
161
161
|
return () => {
|
|
162
162
|
if (ctxValueRef.current.componentScope !== undefined && ctxValueRef.current.shutdownDeferred !== undefined) {
|
|
163
|
-
interrupt(ctxValueRef.current.componentScope, ctxValueRef.current.shutdownDeferred, new StoreInterrupted());
|
|
163
|
+
interrupt(ctxValueRef.current.componentScope, ctxValueRef.current.shutdownDeferred, new StoreInterrupted({ reason: 'unmounting component' }));
|
|
164
164
|
ctxValueRef.current.componentScope = undefined;
|
|
165
165
|
ctxValueRef.current.shutdownDeferred = undefined;
|
|
166
166
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LiveStoreProvider.js","sourceRoot":"","sources":["../src/LiveStoreProvider.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAWhE,OAAO,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"LiveStoreProvider.js","sourceRoot":"","sources":["../src/LiveStoreProvider.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAWhE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAExD,OAAO,EACL,KAAK,EACL,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,MAAM,EACN,KAAK,EACL,WAAW,GACZ,MAAM,yBAAyB,CAAA;AAGhC,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AA0CxD,MAAM,kBAAkB,GAAG,CAAC,KAAgC,EAAE,E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AA;gBACD,WAAW,CAAC,OAAO,CAAC,cAAc,GAAG,SAAS,CAAA;gBAC9C,WAAW,CAAC,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAA;YAClD,CAAC;QACH,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IAExG,OAAO,WAAW,CAAC,OAAO,CAAC,KAAK,CAAA;AAClC,CAAC,CAAA"}
|
|
@@ -40,7 +40,7 @@ describe('LiveStoreProvider', () => {
|
|
|
40
40
|
await waitFor(() => screen.getByText((_) => _.includes('buy milk')));
|
|
41
41
|
expect(appRenderCount).toBe(2);
|
|
42
42
|
abortController.abort();
|
|
43
|
-
await waitFor(() => screen.getByText('LiveStore Shutdown due to
|
|
43
|
+
await waitFor(() => screen.getByText('LiveStore Shutdown due to interrupted', { exact: false }));
|
|
44
44
|
});
|
|
45
45
|
// TODO test aborting during boot
|
|
46
46
|
it('error during boot', async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LiveStoreProvider.test.js","sourceRoot":"","sources":["../src/LiveStoreProvider.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,OAAO,EAAc,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;AAC3F,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,uBAAuB,IAAI,YAAY,EAAE,MAAM,WA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,EAAE,YAAY;gBAE1B,oBAAC,GAAG,OAAG,CACW,CACrB,CAAA;QACH,CAAC,CAAA;QAED,MAAM,CAAC,oBAAC,IAAI,IAAC,WAAW,EAAE,CAAC,GAAI,CAAC,CAAA;QAEhC,MAAM,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAE9B,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,2BAA2B,CAAC,CAAC,CAAC,CAAA;IACzF,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livestore/react",
|
|
3
|
-
"version": "0.3.0-dev.
|
|
3
|
+
"version": "0.3.0-dev.19",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"exports": {
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@opentelemetry/api": "1.9.0",
|
|
26
|
-
"@livestore/common": "0.3.0-dev.
|
|
27
|
-
"@livestore/
|
|
28
|
-
"@livestore/
|
|
26
|
+
"@livestore/common": "0.3.0-dev.19",
|
|
27
|
+
"@livestore/livestore": "0.3.0-dev.19",
|
|
28
|
+
"@livestore/utils": "0.3.0-dev.19"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@opentelemetry/sdk-trace-base": "^1.30.1",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"typescript": "^5.7.3",
|
|
40
40
|
"vite": "^6.1.0",
|
|
41
41
|
"vitest": "^2.1.4",
|
|
42
|
-
"@livestore/adapter-web": "0.3.0-dev.
|
|
42
|
+
"@livestore/adapter-web": "0.3.0-dev.19"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"react": "~19.0.0"
|
|
@@ -71,7 +71,7 @@ describe('LiveStoreProvider', () => {
|
|
|
71
71
|
|
|
72
72
|
abortController.abort()
|
|
73
73
|
|
|
74
|
-
await waitFor(() => screen.getByText('LiveStore Shutdown due to
|
|
74
|
+
await waitFor(() => screen.getByText('LiveStore Shutdown due to interrupted', { exact: false }))
|
|
75
75
|
})
|
|
76
76
|
|
|
77
77
|
// TODO test aborting during boot
|
|
@@ -10,10 +10,21 @@ import type {
|
|
|
10
10
|
ShutdownDeferred,
|
|
11
11
|
Store,
|
|
12
12
|
} from '@livestore/livestore'
|
|
13
|
-
import { createStore,
|
|
13
|
+
import { createStore, StoreInterrupted } from '@livestore/livestore'
|
|
14
14
|
import { errorToString, LS_DEV } from '@livestore/utils'
|
|
15
15
|
import type { OtelTracer } from '@livestore/utils/effect'
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
Cause,
|
|
18
|
+
Deferred,
|
|
19
|
+
Effect,
|
|
20
|
+
Exit,
|
|
21
|
+
identity,
|
|
22
|
+
Logger,
|
|
23
|
+
LogLevel,
|
|
24
|
+
Schema,
|
|
25
|
+
Scope,
|
|
26
|
+
TaskTracing,
|
|
27
|
+
} from '@livestore/utils/effect'
|
|
17
28
|
import type * as otel from '@opentelemetry/api'
|
|
18
29
|
import type { ReactElement, ReactNode } from 'react'
|
|
19
30
|
import React from 'react'
|
|
@@ -41,7 +52,7 @@ interface LiveStoreProviderProps<GraphQLContext extends BaseGraphQLContext> {
|
|
|
41
52
|
otelOptions?: Partial<OtelOptions>
|
|
42
53
|
renderLoading: (status: BootStatus) => ReactElement
|
|
43
54
|
renderError?: (error: UnexpectedError | unknown) => ReactElement
|
|
44
|
-
renderShutdown?: (cause: IntentionalShutdownCause |
|
|
55
|
+
renderShutdown?: (cause: IntentionalShutdownCause | StoreInterrupted) => ReactElement
|
|
45
56
|
adapter: Adapter
|
|
46
57
|
/**
|
|
47
58
|
* In order for LiveStore to apply multiple mutations in a single render,
|
|
@@ -63,10 +74,10 @@ interface LiveStoreProviderProps<GraphQLContext extends BaseGraphQLContext> {
|
|
|
63
74
|
const defaultRenderError = (error: UnexpectedError | unknown) => (
|
|
64
75
|
<>{Schema.is(UnexpectedError)(error) ? error.toString() : errorToString(error)}</>
|
|
65
76
|
)
|
|
66
|
-
const defaultRenderShutdown = (cause: IntentionalShutdownCause |
|
|
77
|
+
const defaultRenderShutdown = (cause: IntentionalShutdownCause | StoreInterrupted) => {
|
|
67
78
|
const reason =
|
|
68
|
-
cause._tag === 'LiveStore.
|
|
69
|
-
?
|
|
79
|
+
cause._tag === 'LiveStore.StoreInterrupted'
|
|
80
|
+
? `interrupted due to: ${cause.reason}`
|
|
70
81
|
: cause.reason === 'devtools-import'
|
|
71
82
|
? 'devtools import'
|
|
72
83
|
: cause.reason === 'devtools-reset'
|
|
@@ -181,7 +192,7 @@ const useCreateStore = <GraphQLContext extends BaseGraphQLContext>({
|
|
|
181
192
|
const interrupt = (
|
|
182
193
|
componentScope: Scope.CloseableScope,
|
|
183
194
|
shutdownDeferred: ShutdownDeferred,
|
|
184
|
-
error:
|
|
195
|
+
error: StoreInterrupted,
|
|
185
196
|
) =>
|
|
186
197
|
Effect.gen(function* () {
|
|
187
198
|
// console.log('[@livestore/livestore/react] interupting', error)
|
|
@@ -213,7 +224,11 @@ const useCreateStore = <GraphQLContext extends BaseGraphQLContext>({
|
|
|
213
224
|
signal,
|
|
214
225
|
}
|
|
215
226
|
if (ctxValueRef.current.componentScope !== undefined && ctxValueRef.current.shutdownDeferred !== undefined) {
|
|
216
|
-
interrupt(
|
|
227
|
+
interrupt(
|
|
228
|
+
ctxValueRef.current.componentScope,
|
|
229
|
+
ctxValueRef.current.shutdownDeferred,
|
|
230
|
+
new StoreInterrupted({ reason: 're-rendering due to changed input props' }),
|
|
231
|
+
)
|
|
217
232
|
ctxValueRef.current.componentScope = undefined
|
|
218
233
|
ctxValueRef.current.shutdownDeferred = undefined
|
|
219
234
|
}
|
|
@@ -240,7 +255,11 @@ const useCreateStore = <GraphQLContext extends BaseGraphQLContext>({
|
|
|
240
255
|
ctxValueRef.current.shutdownDeferred !== undefined &&
|
|
241
256
|
ctxValueRef.current.counter === counter
|
|
242
257
|
) {
|
|
243
|
-
interrupt(
|
|
258
|
+
interrupt(
|
|
259
|
+
ctxValueRef.current.componentScope,
|
|
260
|
+
ctxValueRef.current.shutdownDeferred,
|
|
261
|
+
new StoreInterrupted({ reason: 'Aborted via provided AbortController' }),
|
|
262
|
+
)
|
|
244
263
|
ctxValueRef.current.componentScope = undefined
|
|
245
264
|
ctxValueRef.current.shutdownDeferred = undefined
|
|
246
265
|
}
|
|
@@ -250,7 +269,7 @@ const useCreateStore = <GraphQLContext extends BaseGraphQLContext>({
|
|
|
250
269
|
const componentScope = yield* Scope.make()
|
|
251
270
|
const shutdownDeferred = yield* Deferred.make<
|
|
252
271
|
void,
|
|
253
|
-
UnexpectedError | IntentionalShutdownCause |
|
|
272
|
+
UnexpectedError | IntentionalShutdownCause | StoreInterrupted
|
|
254
273
|
>()
|
|
255
274
|
|
|
256
275
|
ctxValueRef.current.componentScope = componentScope
|
|
@@ -276,13 +295,13 @@ const useCreateStore = <GraphQLContext extends BaseGraphQLContext>({
|
|
|
276
295
|
setContextValue({ stage: 'running', store })
|
|
277
296
|
}).pipe(Scope.extend(componentScope), Effect.forkIn(componentScope))
|
|
278
297
|
|
|
279
|
-
const shutdownContext = (cause: IntentionalShutdownCause |
|
|
298
|
+
const shutdownContext = (cause: IntentionalShutdownCause | StoreInterrupted) =>
|
|
280
299
|
Effect.sync(() => setContextValue({ stage: 'shutdown', cause }))
|
|
281
300
|
|
|
282
301
|
yield* Deferred.await(shutdownDeferred).pipe(
|
|
283
|
-
Effect.tapErrorCause((cause) => Effect.logDebug('[@livestore/livestore/react] shutdown', cause)),
|
|
302
|
+
Effect.tapErrorCause((cause) => Effect.logDebug('[@livestore/livestore/react] shutdown', Cause.pretty(cause))),
|
|
284
303
|
Effect.catchTag('LiveStore.IntentionalShutdownCause', (cause) => shutdownContext(cause)),
|
|
285
|
-
Effect.catchTag('LiveStore.
|
|
304
|
+
Effect.catchTag('LiveStore.StoreInterrupted', (cause) => shutdownContext(cause)),
|
|
286
305
|
Effect.tapError((error) => Effect.sync(() => setContextValue({ stage: 'error', error }))),
|
|
287
306
|
Effect.tapDefect((defect) => Effect.sync(() => setContextValue({ stage: 'error', error: defect }))),
|
|
288
307
|
Effect.exit,
|
|
@@ -305,7 +324,11 @@ const useCreateStore = <GraphQLContext extends BaseGraphQLContext>({
|
|
|
305
324
|
|
|
306
325
|
return () => {
|
|
307
326
|
if (ctxValueRef.current.componentScope !== undefined && ctxValueRef.current.shutdownDeferred !== undefined) {
|
|
308
|
-
interrupt(
|
|
327
|
+
interrupt(
|
|
328
|
+
ctxValueRef.current.componentScope,
|
|
329
|
+
ctxValueRef.current.shutdownDeferred,
|
|
330
|
+
new StoreInterrupted({ reason: 'unmounting component' }),
|
|
331
|
+
)
|
|
309
332
|
ctxValueRef.current.componentScope = undefined
|
|
310
333
|
ctxValueRef.current.shutdownDeferred = undefined
|
|
311
334
|
}
|
package/tmp/pack.tgz
ADDED
|
Binary file
|