Your second approach sounds more logical to me only if the third action depends on the second action, otherwise, it's just redundant.
Events: Best Practices when you need synchronous events
I would like some opinions on this type of situation:
- A piece of content is created
- That content needs an addition from a time consuming task
- Subscribers need to be alerted of the content creation.
These 3 things MUST happen in the order and the last 2 MUST be triggered in an event.
One way of dealing with this situation is creating a ContentWasCreated event and sticking these handlers in the service provider in the order they need to be executed.
The second way of dealing with this is throwing 2 events. The ContentWasCreated event is fired and triggers the time consuming task. When the task completes, it fires a ContentIsReadyToBeSent which handles the alert.
How would you handle this sort of situation. Many times I've run across synchronously dependent events.
Please or to participate in this conversation.