Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Ermashev committed Aug 19, 2020
1 parent 562790d commit 1b60c7a
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ Simple example
'email' => 'tester@gmail.com'
]);
$serviceManager = new EventManager(
$eventManager = new EventManager(
new ServiceManager()
);
// notify subscribers about the action
$serviceManager->trigger('user.created.event', $event);
$eventManager->trigger('user.created.event', $event);
...
Expand All @@ -72,11 +72,11 @@ Collection example
$event = new EventCollection();
$serviceManager = new EventManager(
$eventManager = new EventManager(
new ServiceManager()
);
$serviceManager->trigger('core.config_list.event', $event);
$eventManager->trigger('core.config_list.event', $event);
...
Expand All @@ -100,18 +100,18 @@ Subscribe / unsubscribe example
use Tiny\EventManager\EventManager;
use Tiny\ServiceManager\ServiceManager;
$serviceManager = new EventManager(
$eventManager = new EventManager(
// you may pass any other "PSR"'s compatible container here
new ServiceManager()
);
// subscribe to some events
// we need to pass a listener class name and priority (optional)
$serviceManager->subscribe('user.created.event', TestUserCreatedEvent::class, 100);
$serviceManager->subscribe('user.deleted.event', TestUserDeletedEvent::class, 100);
$eventManager->subscribe('user.created.event', TestUserCreatedEvent::class, 100);
$eventManager->subscribe('user.deleted.event', TestUserDeletedEvent::class, 100);
// we don't want to listen the "user.deleted.event" event any more
$serviceManager->unsubscribe('user.deleted.event', TestUserDeletedEvent::class);
$eventManager->unsubscribe('user.deleted.event', TestUserDeletedEvent::class);
The **priority** is used to manage the exact order of listeners execution, if you need you that your listener will be executed first you need to specify a lower priority than other listeners do

Expand All @@ -127,12 +127,12 @@ Complete example
use Tiny\EventManager\EventManager;
use Tiny\ServiceManager\ServiceManager;
$serviceManager = new EventManager(
$eventManager = new EventManager(
new ServiceManager()
);
// we need to know when new users are created
$serviceManager->subscribe('user.created.event', TestUserCreatedEvent::class);
$eventManager->subscribe('user.created.event', TestUserCreatedEvent::class);
// notify subscribers about a new user
$event = new Event([
Expand All @@ -141,7 +141,7 @@ Complete example
'email' => 'tester@gmail.com'
]);
$serviceManager->trigger('user.created.event', $event);
$eventManager->trigger('user.created.event', $event);
// the event's handler
class TestUserCreatedEvent
Expand Down

0 comments on commit 1b60c7a

Please sign in to comment.