Add DeadEvent #9
Labels
No Label
1
13
2
21
3
34
5
55
8
bug
core
could have
duplicate
enhancement
help wanted
must have
proc
question
should have
wont have
L
M
S
XL
bug
bugfix
discussion
documentation
feature
maintenance
postponed
refactoring
wontfix
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: zdm/event-bus#9
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "f/dead-event"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.
c8e38178bb
to1ef40fce18
👍
@ -0,0 +24,4 @@
}
/**
* @return the event bus that originated this event
I have ammended my original commit.
@ -82,2 +76,2 @@
handler.execute(event);
}
Iterator<EventHandler> handlers = getHandlersFor(event.getClass());
if (handlers.hasNext()) {
that if should be useless as the
loop also checks in the first iteration,
which is exactly the difference to the
loop.
I need the
else (if)
case here as well, but unfortunately this is not Python.@ -84,0 +83,4 @@
} else {
handlers.next().execute(event);
}
} else if (!(event instanceof DeadEvent)) {
this would be a little bit different then.
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.
@ -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<>());
Why do you need that now?
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.
1ef40fce18
to526899e887
526899e887
tob2fe3a9d6c