From 7f757c3ce0ea1d77f1c7fabdb73ac850af1b306d Mon Sep 17 00:00:00 2001 From: Eliott Wantz Date: Wed, 13 May 2026 15:02:35 -0400 Subject: [PATCH] refactor effect.fn --- index.ts | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/index.ts b/index.ts index f02173f..b85072d 100644 --- a/index.ts +++ b/index.ts @@ -92,19 +92,18 @@ const TodoRepositoryLive = Layer.effect( Effect.withSpan("TodoRepository.list"), ), get, - create: (input) => - Effect.gen(function* () { - const timestamp = now(); - const todo: Todo = { - id: crypto.randomUUID(), - title: input.title, - completed: input.completed ?? false, - createdAt: timestamp, - updatedAt: timestamp, - }; - yield* Ref.update(todos, (store) => new Map(store).set(todo.id, todo)); - return todo; - }).pipe(Effect.withSpan("TodoRepository.create")), + create: Effect.fn("TodoRepository.create")(function* (input) { + const timestamp = now(); + const todo: Todo = { + id: crypto.randomUUID(), + title: input.title, + completed: input.completed ?? false, + createdAt: timestamp, + updatedAt: timestamp, + }; + yield* Ref.update(todos, (store) => new Map(store).set(todo.id, todo)); + return todo; + }), update: (id, input) => Effect.gen(function* () { const existing = yield* get(id); -- 2.51.2