Skip to content

Commit

Permalink
Move towards using queries to inform sagas
Browse files Browse the repository at this point in the history
Refs #2100
  • Loading branch information
thewilkybarkid committed Nov 21, 2024
1 parent 7d83519 commit 4d1a2ad
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Comments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export const ReactToCommentEvents: Layer.Layer<
never,
never,
| CommentEvents
| EventStore
| GetComment
| HandleCommentCommand
| DoesUserHaveAVerifiedEmailAddress
Expand All @@ -128,6 +129,7 @@ export const ReactToCommentEvents: Layer.Layer<
> = Layer.scopedDiscard(
Effect.gen(function* () {
const commentEvents = yield* CommentEvents
const eventStore = yield* EventStore
const dequeue = yield* PubSub.subscribe(commentEvents)

yield* pipe(
Expand All @@ -143,7 +145,9 @@ export const ReactToCommentEvents: Layer.Layer<
),
Match.when({ event: { _tag: 'CommentPublicationWasRequested' } }, ({ commentId }) =>
pipe(
React.AssignCommentADoiWhenPublicationWasRequested(commentId),
eventStore.getAllEvents,
Effect.andThen(events => Queries.GetACommentInNeedOfADoi(events)),
Effect.andThen(React.AssignCommentADoiWhenPublicationWasRequested),
Effect.tapError(() => Effect.annotateLogs(Effect.logError('ReactToCommentEvents failed'), { commentId })),
),
),
Expand Down

0 comments on commit 4d1a2ad

Please sign in to comment.