Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/bombshell-dev/playground.
Something went wrong. Try again.
734 B · 24 lines
TypeScript
at focus-stack
12345678910111213141516171819202122232425// oxlint-disable require-yieldimport type { Api, Operation, Result } from "effection";import { createApi } from "effection/experimental";import type { Node } from "./types.ts";import { TreeContext } from "./state.ts";
export interface Dispatch { dispatch(event: unknown): Operation<Result<true>>; getNodeById(id: string): Operation<Node | undefined>;}
export const DispatchApi: Api<Dispatch> = createApi<Dispatch>( "freedom:dispatch", { *dispatch(_event: unknown): Operation<Result<true>> { return { ok: false, error: new Error("unhandled") }; },
*getNodeById(id: string): Operation<Node | undefined> { const tree = yield* TreeContext.expect(); return tree.nodes.get(id); }, },);