Skip to content

Instantly share code, notes, and snippets.

@frankdejonge
Created November 27, 2018 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frankdejonge/e64da3a093b6380910891214f1a6c770 to your computer and use it in GitHub Desktop.
Save frankdejonge/e64da3a093b6380910891214f1a6c770 to your computer and use it in GitHub Desktop.
<?php
final class EventDispatcher {
private $listeners = [];
public function listen(callable $listener)
{
$this->listeners[] = $listener;
}
public function dispatch(object $event)
{
foreach ($this->listeners as $listener) $listener($event);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment