Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions doc/event_bus.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,14 @@ every event subscriber will be fully loaded, even though it is not going to be u
use SimpleBus\Message\CallableResolver\CallableCollection;
use SimpleBus\Message\CallableResolver\ServiceLocatorAwareCallableResolver;

// Provide a map of event names to callables. You can provide actual callables, or lazy-loading ones.
// Provide a map of event names to callables. You can provide actual callables, or lazy-loading ones using a ServiceLocator
$eventSubscribersByEventName = [
'Fully\Qualified\Class\Name\Of\Event' => [
['event_subscriber_service_id', 'notify'],
Fully\Qualified\Class\Name\Of\Event::class => [
$fqcn = My\Class\Name::class, // Will use ServiceLocator for instantiation and invoke $instance->notify() if that function exists on the $instance
$object = new My\Class\Name(), // Will not use ServiceLocator and invoke $object->notify()
$callable1 = [My\Class\Name::class, 'notify'], // Will not use ServiceLocator and invoke My\Class\Name::notify() statically
$callable2 = [new My\Class\Name(), 'notify'], // Will not use ServiceLocator and invoke $serviceInstance->notify()
$callable3 = ['event_subscriber_service_id', 'notify'], // Will use ServiceLocator to instantiate service and invoke '$object->notify()' method
['another_event_subscriber_service_id', 'notify']
]
];
Expand Down