How to create store events and handlers external to the store #91
-
Hi, Could you please update the Store Events page on how this maybe done. I do see warnings at least twice about circular references, so it seems others might be having the same issue. Thanks NB. I would like to create the events and handlers external to the store just to reduce cluttering in the store. Cheers |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Registering an Event and a handler outside the stores is well-supported and should generally not introduce any circular reference error. What could introduce a circular reference, are reflexive or transitively looping event handler relations: If it really is the registration that causes all of this for you, could you post some code to troubleshoot? |
Beta Was this translation helpful? Give feedback.
Registering an Event and a handler outside the stores is well-supported and should generally not introduce any circular reference error.
Check out the following stackblitz: https://stackblitz.com/edit/signalstory-discussion-91?file=src%2Fmain.ts
What could introduce a circular reference, are reflexive or transitively looping event handler relations:
You publish EventA and EventAHandler1 publishes EventB whereas EventBHandler1 again publishes EventA => Infinite Loop.
This can get quite complicated to track if you have a large chain of events, for example, if EventA leads to EventB, leads to EventC, leads to EventD , and so on, which finally leads back again to EventA being published.
If it…