Skip to content

Commit

Permalink
Fix support for multiple hooks in attach_hook
Browse files Browse the repository at this point in the history
`Axon.attach_hook` should accumulate hooks instead of overwriting the `node.hooks` variable with the most recent hook
  • Loading branch information
NduatiK committed May 24, 2023
1 parent bcafdef commit cb0b347
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/axon.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3139,7 +3139,7 @@ defmodule Axon do

updated_nodes =
Map.update!(nodes, id, fn axon_node ->
%{axon_node | hooks: [{on_event, mode, fun}]}
%{axon_node | hooks: [{on_event, mode, fun} | axon_node.hooks]}
end)

%{axon | nodes: updated_nodes}
Expand Down

0 comments on commit cb0b347

Please sign in to comment.