Add DeadEvent #9

Merged
kske merged 2 commits from f/dead-event into develop 2 years ago
kske commented 2 years ago
Owner

A dead event is dispatched when another event is not handled by any event handler. It wraps the unhandled event and can be dispatched to to dead event listeners. If no such listener is defined, a warning is logged instead.

Dead events can be useful to validate the event distribution system.

A dead event is dispatched when another event is not handled by any event handler. It wraps the unhandled event and can be dispatched to to dead event listeners. If no such listener is defined, a warning is logged instead. Dead events can be useful to validate the event distribution system.
kske added the
enhancement
label 2 years ago
kske self-assigned this 2 years ago
kske added 1 commit 2 years ago
0036dc4829
Add DeadEvent
kske requested review from delvh 2 years ago
kske requested review from DieGurke 2 years ago
kske removed review request for DieGurke 2 years ago
kske force-pushed f/dead-event from c8e38178bb to 1ef40fce18 2 years ago
delvh approved these changes 2 years ago
delvh left a comment
Owner

👍

👍
}
/**
* @return the event bus that originated this event
delvh commented 2 years ago
Owner
 *  that dispatched this event
```java * … that dispatched this event ```
kske commented 2 years ago
Poster
Owner

I have ammended my original commit.

I have ammended my original commit.
delvh marked this conversation as resolved
handler.execute(event);
}
Iterator<EventHandler> handlers = getHandlersFor(event.getClass());
if (handlers.hasNext()) {
delvh commented 2 years ago
Owner

that if should be useless as the

while() {}

loop also checks in the first iteration,
which is exactly the difference to the

do{}while()

loop.

that **if** should be useless as the ```java while() {} ``` loop also checks in the first iteration, which is exactly the difference to the ```java do{}while() ``` loop.
kske commented 2 years ago
Poster
Owner

I need the else (if) case here as well, but unfortunately this is not Python.

I need the `else (if)` case here as well, but unfortunately this is not Python.
kske marked this conversation as resolved
} else {
handlers.next().execute(event);
}
} else if (!(event instanceof DeadEvent)) {
delvh commented 2 years ago
Owner

this would be a little bit different then.

this would be a little bit different then.
kske commented 2 years ago
Poster
Owner

That's why I use the if statement. I could use a boolean flag instead, but the iterator logic should be more efficient and arguably more readable here.

That's why I use the if statement. I could use a boolean flag instead, but the iterator logic should be more efficient and arguably more readable here.
kske marked this conversation as resolved
// Get handlers defined for the event class
Set<EventHandler> handlers = bindings.getOrDefault(eventClass, new TreeSet<>());
TreeSet<EventHandler> handlers = bindings.getOrDefault(eventClass, new TreeSet<>());
delvh commented 2 years ago
Owner

Why do you need that now?

Why do you need that now?
kske commented 2 years ago
Poster
Owner

I don't, but why unnecessarily obfuscate the type? The fact that this is a tree set is important here as it guarantees the event handler order, so the variable type might as well reflect this.

I don't, but why unnecessarily obfuscate the type? The fact that this is a tree set is important here as it guarantees the event handler order, so the variable type might as well reflect this.
delvh marked this conversation as resolved
kske force-pushed f/dead-event from 1ef40fce18 to 526899e887 2 years ago
kske force-pushed f/dead-event from 526899e887 to b2fe3a9d6c 2 years ago
kske added the
core
label 2 years ago
kske requested review from DieGurke 2 years ago
DieGurke approved these changes 2 years ago
kske merged commit 0f9b64be48 into develop 2 years ago
kske deleted branch f/dead-event 2 years ago

Reviewers

delvh approved these changes 2 years ago
DieGurke approved these changes 2 years ago
The pull request has been merged as 0f9b64be48.
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
3 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: zdm/event-bus#9
Loading…
There is no content yet.