Skip to content
Myr

import.ts

This file

Path

apps/web/src/client/import.ts

30 lines · 1018 bytes · TypeScript

Last changed by

Merge build/comments-web-rest into mainoscabrielbefore adoption0eb1248

History of this file

Take it

Merge build/1411-web-import into mainoscabrielbefore adoption059c75c

lines 1–8why, one step back
1import type { InitProject } from "@repo/protocol/contracts";
2import type { ProjectName } from "@repo/protocol/ids";3import { Effect, Option } from "effect";4import { AsyncResult, Reactivity } from "effect/reactivity";56import { ContractsClient } from "../surfaces.ts";7import { keys } from "./keys.ts";8

Merge build/comments-web-rest into mainoscabrielbefore adoption0eb1248

line 9why, one step back
9// While a later import is on its way, or was refused, the atom still holds an earlier project; that names none here.

Merge build/1411-web-import into mainoscabrielbefore adoption059c75c

lines 10–30why, one step back
10export const importMade = (
11 result: AsyncResult.AsyncResult<12 typeof InitProject.successSchema.Type,13 unknown14 >15): Option.Option<ProjectName> =>16 AsyncResult.isSuccess(result) && !result.waiting17 ? Option.some(result.value.project)18 : Option.none();1920export const importAtom = ContractsClient.runtime.fn<21 typeof InitProject.payloadSchema.Type22>()(23 Effect.fnUntraced(function* (input) {24 const client = yield* ContractsClient;2526 return yield* client("initProject", input).pipe(27 Reactivity.mutation([...keys.front(), ...keys.project(input.project)])28 );29 })30);