Skip to content
Myr

events.ts

This file

Path

apps/web/src/client/events.ts

61 lines · 1.6 KiB · TypeScript

Last changed by

Merge build/comments-web-rest into mainoscabrielbefore adoption0eb1248

History of this file

Take it

Merge build/comments-web-rest into mainoscabrielbefore adoption0eb1248

line 1why, one step back
1// Over JSON the platform replays the kept events in one response and ends; only the framed `/rpc` keeps the stream open.

Fold every page's project events once, keep Markdown off the first load, and cache what never changesoscabrielbefore adoption38e5215

lines 2–3why, one step back
2import { ProjectEvent } from "@repo/protocol/domain/event";
3import type { LandingView } from "@repo/protocol/domain/landing";

Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726

line 4why, one step back
4import type { ProjectName } from "@repo/protocol/ids";

Fold every page's project events once, keep Markdown off the first load, and cache what never changesoscabrielbefore adoption38e5215

lines 5–10why, one step back
5import { Effect, Stream } from "effect";
6import { Atom } from "effect/reactivity";78import { ContractsClient } from "../surfaces.ts";9import { keys } from "./keys.ts";10

Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726

lines 11–26why, one step back
11export {
12 askStates,13 familyMarks,14 lastSeq,15 stampsFrom,16 whoseMove,17} from "../features/shared/ask-progress.ts";1819export type {20 AskProgress,21 Family,22 Mark,23 Move,24 Round,25} from "../features/shared/ask-progress.ts";26

Fold every page's project events once, keep Markdown off the first load, and cache what never changesoscabrielbefore adoption38e5215

lines 27–30why, one step back
27const RECENT = 20;
2829export const projectEventsAtom = Atom.family((project: ProjectName) =>30 Atom.withServerValueInitial(

Review fixes for 1202oscabrielbefore adoption512af5a

line 31why, one step back
31 ContractsClient.runtime.factory.withReactivity(keys.events(project))(

Fold every page's project events once, keep Markdown off the first load, and cache what never changesoscabrielbefore adoption38e5215

lines 32–61why, one step back
32 ContractsClient.runtime.atom(
33 Effect.gen(function* () {34 const client = yield* ContractsClient;3536 const events: readonly ProjectEvent[] = yield* Stream.runCollect(37 client("watch", { project, since: 0 })38 );3940 return events;41 })42 )43 )44 )45);4647export const recentLandings = (48 events: readonly ProjectEvent[]49): readonly LandingView[] =>50 events51 .flatMap((event) =>52 ProjectEvent.guards.Landed(event) ? [event.landing] : []53 )54 .toReversed()55 .slice(0, RECENT);5657export const recentLandingsAtom = Atom.family((project: ProjectName) =>58 Atom.withServerValueInitial(59 Atom.mapResult(projectEventsAtom(project), recentLandings)60 )61);