MCPcopy Create free account
hub / github.com/CodeForBreakfast/eventsourcing / processCommand

Function processCommand

examples/todo-app/src/cli.ts:90–110  ·  view source on GitHub ↗
(
  todoState: Readonly<Option.Option<TodoState>>,
  command: (
    state: Readonly<Option.Option<TodoState>>
  ) => Effect.Effect<ReadonlyArray<TodoEvent>, Error>,
  todoId: TodoId,
  eventNumber: number,
  successMessage: string,
  noOpMessage: string
)

Source from the content-addressed store, hash-verified

88};
89
90const processCommand = (
91 todoState: Readonly<Option.Option<TodoState>>,
92 command: (
93 state: Readonly<Option.Option<TodoState>>
94 ) => Effect.Effect<ReadonlyArray<TodoEvent>, Error>,
95 todoId: TodoId,
96 eventNumber: number,
97 successMessage: string,
98 noOpMessage: string
99) =>
100 pipe(
101 todoState,
102 command,
103 Effect.flatMap((events) =>
104 handleConditional(
105 events,
106 commitAndPublish(todoId, eventNumber, events, successMessage),
107 Console.log(noOpMessage)
108 )
109 )
110 );
111
112const executeCommand = (
113 todoId: TodoId,

Callers 1

executeCommandFunction · 0.85

Calls 2

commitAndPublishFunction · 0.85
handleConditionalFunction · 0.70

Tested by

no test coverage detected