(
todoId: TodoId,
command: (
state: Readonly<Option.Option<TodoState>>
) => Effect.Effect<ReadonlyArray<TodoEvent>, Error>,
successMessage: string,
noOpMessage: string
)
| 110 | ); |
| 111 | |
| 112 | const executeCommand = ( |
| 113 | todoId: TodoId, |
| 114 | command: ( |
| 115 | state: Readonly<Option.Option<TodoState>> |
| 116 | ) => Effect.Effect<ReadonlyArray<TodoEvent>, Error>, |
| 117 | successMessage: string, |
| 118 | noOpMessage: string |
| 119 | ) => |
| 120 | pipe( |
| 121 | todoId, |
| 122 | TodoAggregateRoot.load, |
| 123 | Effect.tap((state) => |
| 124 | Console.log( |
| 125 | `Loaded state: nextEventNumber=${state.nextEventNumber}, hasData=${Option.isSome(state.data)}` |
| 126 | ) |
| 127 | ), |
| 128 | Effect.flatMap((state) => |
| 129 | processCommand( |
| 130 | state.data, |
| 131 | command, |
| 132 | todoId, |
| 133 | state.nextEventNumber, |
| 134 | successMessage, |
| 135 | noOpMessage |
| 136 | ) |
| 137 | ) |
| 138 | ); |
| 139 | |
| 140 | const completeTodo = (todoId: TodoId) => |
| 141 | executeCommand( |
no test coverage detected