Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Recipe] Link events from one stream to another #16

Open
slashdotdash opened this issue May 3, 2020 · 1 comment
Open

[Recipe] Link events from one stream to another #16

slashdotdash opened this issue May 3, 2020 · 1 comment

Comments

@slashdotdash
Copy link
Member

How to link an existing event from one stream to another.

Use an event handler to link events of a given type into another stream.

The source event_id is accessible via metadata:

def handle(%ProductSold{} = event, metadata) do
  %ProductSold{user_id: user_id} = event

  event_id = Map.get(metadata, :event_id)

  MyApp.EventStore.link_to_stream(user_id, :any_version, [event_id])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants