Skip to content

Expect sequence of events in saga #903

Open
@boenrobot

Description

@boenrobot

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ ] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

The docs state for sagas that a saga "can combine, merge, filter [...] events streams."

Does that mean that a saga could trigger a command after a sequence of events? How to do that though? How to monitor different types of events, determine if they're related to one another somehow, and trigger the command only once two or more related events are found in the stream?

Expected behavior

There should be an example of combining two events into a stream and if possible, establishing a simple relation between them. More complex business logic (more events, more complex relations between the events) could extrapolate from that.

I would contribute to docs, if I actually knew the answers to the above questions.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

As hinted in issues like nestjs/cqrs#64, the distinction between a saga and an event handler is kind of merky... I for one thought that a saga differs exactly in that it can watch for related events, whereas an event handler is specifically for one event at a time.

If that's correct, the docs should give an example demonstrating this rather than simply an alternative to an event handler. If not correct, there should be a minimal example that illustrates where one should use a handler vs. where to use a saga.

Environment


Nest version: latest

 
For Tooling issues:
- Node version: latest  
- Platform: all 

Others:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions