This repository was archived by the owner on Jan 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit 144cd39
committed
Initial EventManager refactor
- Removes:
- SharedEventAggregateAwareInterface::detachAggregate
- SharedEventManagerAwareInterface::getSharedManager and unsetSharedManager.
- SharedEventManagerInterface::detach
- EventManagerInterface::detach, detachAggregate, and addIdentifiers.
- Modifies:
- EventManagerInterface::attach renames $callback to $listener, typehints
it as callable, and makes it required. The method no longer has a return
value.
- EventManagerInterface::trigger now typehints the $callback argument as
callable
- SharedEventManagerInterface::getListeners now markes the $event argument as
optional, and returns an array.
- Adds:
- Exception\RuntimeException
All implementations of the above interfaces were modified accordingly.
SharedEventManager was modified to store the various listeners within structured
arrays instead of EventManager and/or PriorityQueue instances.
EventManager was altered to accept both identifiers and a SharedEventManager
instance to the constructor. Additionally, once both identifiers and the shared
manager instance are present, a call is made to a new method,
`prepareListeners`; this method does the following:
- It loops through all identifiers,
- pulls listeners from the shared manager based on those identifiers,
- caching wildcard listeners for later,
- and attaches all other listeners directly to the instance.
It then loops through wildcard identifiers, with the same logic.
Finally, it loops through any known events, and attaches all wildcard listeners
to each of the events.
The BC breaks from this approach are as follows:
- Obviously, if you used any of the removed methods, they are no longer
available.
- CallbackHandler instances can no longer be used when calling `attach()`
- Any shared listeners attached *after* the instance is created will not be
executed. This means attachment of shared listeners should be done early,
preferably during application bootstrap, but really anytime before an instance
is fetched from the service manager.
The changes, however, are essentially BC with the current solution. My initial
benchmarks show that execution is around twice as fast as the current solution.1 parent 72d7343 commit 144cd39Copy full SHA for 144cd39
File tree
Expand file treeCollapse file tree
7 files changed
+178
-386
lines changedFilter options
- src
- Exception
Expand file treeCollapse file tree
7 files changed
+178
-386
lines changed
0 commit comments