-
Notifications
You must be signed in to change notification settings - Fork 31
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
Catch-all events #19
Comments
Do you mean to, for example, be able to log all events? |
It's by design in that Entities publish events by inheriting the behavior of Node's standard EventEmitter class. If I were to do this, I would just
If that's not fancy enough for you (I tend to prefer code that is less fancy, and more obvious) you could combine the top two answers from here and monkey patch your entities to use EventEmitter2, which would allow you to use wildcards to determine which events fire your listeners. You could create a little factory function which instantiates your entity, monkey patches it, and gives it back to you - ready to roll. |
Thanks for you reply. What I meant is if it is possible to catch all events on for example on the repository. This makes it possible to have my read services listen to all events from all entities. Please, if this is bad design - let me know. More specifically, current situation: var repository = ...
var card = new Card();
card.initialize(cmd);
card.on('initialize', () => ...);
repository.commit(card); Preferred situation: // read side
repository.on('initialize', () => {
// update read side
});
// write side
var repository = ...
var card = new Card();
card.initialize(cmd);
repository.commit(card); |
The top scenario you have is preferred, as it's the actual entity being On Sep 20, 2016 2:44 PM, "Joey Osseman" notifications@github.com wrote:
|
Thanks for the quick reply, one last question :-). How would my read side respond on these events? In other words, how would they know an event was thrown? |
You'll publish a message to a read-side process, which will instruct it to On Sep 20, 2016 3:14 PM, "Joey Osseman" notifications@github.com wrote:
|
I will look into it, thanks! |
Hi Matt,
I was trying out your library, works great. I like the simplicity!
However I wan't to catch all events using one single event handler, but it seems it currently only supports catching events on instances of Entities. Is this by design?
Many thanks,
Joey
The text was updated successfully, but these errors were encountered: