-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Milestone
Description
Proposal
Provide a preprocessing step in event dispatch, allowing it to flexibly change channels of the event before sending it through dispatch logic, or cancelling them.
Example
Event:
interface AccountMoneyChangeEvent : Event {
val amount: Int
}Preprocessor:
class AccountMoneyChangeEventPreprocessor : EventDispatchPreprocessor<AccountMoneyChangeEvent> {
fun onPreprocess(event: AccountMoneyChangeEvent, dispatch: DispatchConfiguration) {
if (event.amount < 0) {
dispatch.channels += ChannelSet.Include("withdraw")
} else if (event.amount > 0) {
dispatch.channels += ChannelSet.Include("deposit")
} else {
dispatch.cancel()
}
}
}
eventManager.registerPreprocessor<AccountMoneyChangeEvent>(AccountMoneyChangeEventPreprocessor())Also, if Characteristics get implemented, the preprocessor could also change characteristics of events, but this will occur after Factory Characteristic Handling, so the preprocessor will have priority.
Downsides
A Dispatch Preprocessor could make it harder to figure why a event is not being dispatched as expected.
Metadata
Metadata
Assignees
Labels
No labels