Skip to content

Commit

Permalink
added stopPropagation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
n0nag0n committed Mar 4, 2025
1 parent 4b7cd68 commit 79efffc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion flight/core/EventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ public function trigger(string $event, ...$args): void
{
if (isset($this->listeners[$event]) === true) {
foreach ($this->listeners[$event] as $callback) {
call_user_func_array($callback, $args);
$result = call_user_func_array($callback, $args);

// If you return false, it will break the loop and stop the other event listeners.
if ($result === false) {
break; // Stop executing further listeners
}
}
}
}
Expand Down

0 comments on commit 79efffc

Please sign in to comment.