File tree Expand file tree Collapse file tree 3 files changed +42
-5
lines changed Expand file tree Collapse file tree 3 files changed +42
-5
lines changed Original file line number Diff line number Diff line change @@ -56,11 +56,31 @@ $eventDispatcher = $factory->__invoke($container);
5656$container->set(EventDispatcherInterface::class, $eventDispatcher);
5757````
5858
59+ #### Async Event Dispatcher Factory
60+
61+
62+
63+ ``` bash
64+ composer require react/event-loop
65+ ```
66+
67+ ```` php
68+ <?php
69+
70+ use Antidot\Event\Container\AsyncEventDispatcherFactory;
71+ use Psr\EventDispatcher\EventDispatcherInterface;
72+
73+ $factory = new AsyncEventDispatcherFactory();
74+
75+ $eventDispatcher = $factory->__invoke($container);
76+ $container->set(EventDispatcherInterface::class, $eventDispatcher);
77+ ````
78+
5979## Usage
6080
6181### Send events
6282
63- ```` php
83+ ``` php
6484<?php
6585
6686use Psr\EventDispatcher\EventDispatcherInterface;
@@ -69,5 +89,20 @@ use Psr\EventDispatcher\EventDispatcherInterface;
6989$eventDispatcher = $container->get(EventDispatcherInterface::class);
7090
7191$eventDispatcher->dispatch(SomeEvent::occur());
92+ ```
7293
73- ````
94+ ### Send events Async mode
95+
96+ ``` php
97+ <?php
98+
99+ use Psr\EventDispatcher\EventDispatcherInterface;
100+ use React\EventLoop\Loop;
101+
102+ /** @var \Psr\Container\ContainerInterface $container */
103+ $eventDispatcher = $container->get(EventDispatcherInterface::class);
104+
105+ $eventDispatcher->dispatch(SomeEvent::occur());
106+
107+ Loop::run()
108+ ```
Original file line number Diff line number Diff line change 1414 ],
1515 "require" : {
1616 "php" : " ^7.4|^8.0" ,
17- "psr/event-dispatcher" : " ^1.0" ,
18- "react/event-loop" : " ^1.2"
17+ "psr/event-dispatcher" : " ^1.0"
1918 },
2019 "require-dev" : {
2120 "infection/infection" : " ^0.21.0" ,
2221 "phpro/grumphp" : " ^1.0" ,
2322 "phpstan/phpstan" : " ^0.12" ,
2423 "phpunit/phpunit" : " ^8.0 || ^9.0" ,
24+ "react/event-loop" : " ^1.2" ,
2525 "squizlabs/php_codesniffer" : " ^3.4" ,
2626 "symfony/var-dumper" : " ^4.2 || ^5.0" ,
2727 "vimeo/psalm" : " ^4.4"
5454 "config" : {
5555 "sort-packages" : true
5656 },
57+ "suggest" : {
58+ "react/event-loop" : " If you want to run Async Event Dispatcher implementation."
59+ },
5760 "extra" : {
5861 "laminas" : {
5962 "config-provider" : " Antidot\\ Event\\ Container\\ Config\\ ConfigProvider"
Original file line number Diff line number Diff line change 33namespace Antidot \Test \Event ;
44
55use Antidot \Event \AsyncEventDispatcher ;
6- use Antidot \Event \EventDispatcher ;
76use Antidot \Event \ListenerInterface ;
87use PHPUnit \Framework \TestCase ;
98use Psr \EventDispatcher \ListenerProviderInterface ;
You can’t perform that action at this time.
0 commit comments