Open History to see the last commit
1import { Connection } from "@t3tools/client-runtime/connection";
2import { shellSnapshotLoaderLayer } from "@t3tools/client-runtime/state/shell";
3import { threadSnapshotLoaderLayer } from "@t3tools/client-runtime/state/threads";
4import * as Layer from "effect/Layer";
5import { Atom } from "effect/unstable/reactivity";
6
7import { runtimeContextLayer } from "../lib/runtime";
8import {
9 backgroundActivityObserverLayer,
10 backgroundActivityReporterLayer,
11} from "../lib/backgroundActivityReporter";
12import { connectionPlatformLayer } from "./platform";
13
14const providedConnectionPlatformLayer = connectionPlatformLayer.pipe(
15 Layer.provide(runtimeContextLayer),
16);
17
18const snapshotLoaderLayer = Layer.merge(threadSnapshotLoaderLayer, shellSnapshotLoaderLayer);
19
20type ConnectionLayerSource =
21 | typeof Connection.layer
22 | typeof snapshotLoaderLayer
23 | typeof runtimeContextLayer
24 | typeof connectionPlatformLayer
25 | typeof backgroundActivityObserverLayer
26 | typeof backgroundActivityReporterLayer;
27
28const providedClientConnectionLayer = Layer.merge(Connection.layer, snapshotLoaderLayer).pipe(
29 Layer.provideMerge(
30 Layer.mergeAll(
31 runtimeContextLayer,
32 providedConnectionPlatformLayer,
33 backgroundActivityObserverLayer,
34 ),
35 ),
36);
37
38const connectionLayer = backgroundActivityReporterLayer.pipe(
39 Layer.provideMerge(providedClientConnectionLayer),
40);
41
42export const connectionAtomRuntime: Atom.AtomRuntime<
43 Layer.Success<ConnectionLayerSource>,
44 Layer.Error<ConnectionLayerSource>
45> = Atom.runtime(connectionLayer);