Add DeadEvent #9

Merged
kske merged 2 commits from f/dead-event into develop 2021-02-21 09:16:33 +01:00
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 2021-02-20 21:45:00 +01:00
kske self-assigned this 2021-02-20 21:45:00 +01:00
kske added 1 commit 2021-02-20 21:45:00 +01:00
A dead events wraps an event that was dispatched but not delivered to
any handler. The dead event is than dispatched to dedicated handlers.
kske requested review from delvh 2021-02-20 21:45:03 +01:00
kske requested review from mpk 2021-02-20 21:45:04 +01:00
kske removed review request for mpk 2021-02-20 21:50:50 +01:00
kske force-pushed f/dead-event from c8e38178bb to 1ef40fce18 2021-02-20 21:52:27 +01:00 Compare
delvh approved these changes 2021-02-20 22:01:45 +01:00
delvh left a comment
Owner

👍

👍
@ -0,0 +24,4 @@
}
/**
* @return the event bus that originated this event
Owner
 *  that dispatched this event
```java * … that dispatched this event ```
Author
Owner

I have ammended my original commit.

I have ammended my original commit.
delvh marked this conversation as resolved
@ -82,2 +76,2 @@
handler.execute(event);
}
Iterator<EventHandler> handlers = getHandlersFor(event.getClass());
if (handlers.hasNext()) {
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.
Author
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
@ -84,0 +83,4 @@
} else {
handlers.next().execute(event);
}
} else if (!(event instanceof DeadEvent)) {
Owner

this would be a little bit different then.

this would be a little bit different then.
Author
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
@ -99,3 +111,3 @@
// Get handlers defined for the event class
Set<EventHandler> handlers = bindings.getOrDefault(eventClass, new TreeSet<>());
TreeSet<EventHandler> handlers = bindings.getOrDefault(eventClass, new TreeSet<>());
Owner

Why do you need that now?

Why do you need that now?
Author
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 2021-02-20 22:08:41 +01:00 Compare
kske force-pushed f/dead-event from 526899e887 to b2fe3a9d6c 2021-02-20 22:12:02 +01:00 Compare
kske added the
core
label 2021-02-20 22:21:14 +01:00
kske requested review from mpk 2021-02-21 09:10:08 +01:00
mpk approved these changes 2021-02-21 09:10:41 +01:00
kske merged commit 0f9b64be48 into develop 2021-02-21 09:16:33 +01:00
kske deleted branch f/dead-event 2021-02-21 09:16:39 +01:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: zdm/event-bus#9
No description provided.