php-ddd / domain-event Goto Github PK
View Code? Open in Web Editor NEWTools to create the domain layer of your DDD application
License: MIT License
Tools to create the domain layer of your DDD application
License: MIT License
From your code I see that after an event is raised, it must be handled by a particular event listener. And this event listener must be registered in domain event locator, or you wont be able to execute the event. By doing this, you have to manually register event listener at some point of your code, and this is cumbersome. As the application grows and multiple events need to be triggered, it becomes complex to add event listeners manually.
I was wondering, why do you need this behavior? Why cannot you just implement the handler method inside the event object itself, so users do not have to register event listeners manually? Or maybe, you can make it possible to enable easy mapping between each event and its handler(if you want event to be ignorant of how it will be handlered), so the event locator will automatically create an event listener object for each event(ie. map event PurchaseOrderCreated to event listener PurchaseOrderCreatedHandler).
This way, when you iterate through events and publish them through event bus, the event bus will use event locator to automatically map an event to its listener. You wont need to register event listener/handler manually anymore, the code becomes more concise.
Of course, registration of custom event listeners/handlers introduce more flexibility, so it can always be left of as an option. I just personally think that registering event listeners manually can be problematic as the application grows, and it's also confusing where should we register event listeners(in MVC controller, application service, repository?).
You can test cody style in StyleCI and you can use Symfony preset.
Event listeners should be able to listen to Event in as many way as the language allow us:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.