Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

runtime.ts

50 lines1.6 KB

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