@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 17 lines 614 Bytes
Raw
1 import type { EnvironmentId } from "@t3tools/contracts";
2 import { Atom } from "effect/reactivity";
3
4 export const environmentIdsKey = (environmentIds: ReadonlyArray<EnvironmentId>) =>
5 environmentIds.join("\n");
6
7 /** Key by environment ids so equal input lists reuse the atom and snapshot. */
8 export function environmentAtomList<A>(
9 label: string,
10 atom: (environmentId: EnvironmentId) => Atom.Atom<A>,
11 ) {
12 return Atom.family((key: string) =>
13 Atom.make((get) =>
14 key === "" ? [] : (key.split("\n") as EnvironmentId[]).map((id) => get(atom(id))),
15 ).pipe(Atom.withLabel(`${label}:${key}`)),
16 );
17 }