Comments (10)
Benchmark should be put together in order to check it.
from event-dispatcher.
Honestly, I would propose not supporting generic callables altogether.
Having support for invokable objects / closures should be more than enough?
Also: https://wiki.php.net/rfc/closurefromcallable
from event-dispatcher.
Maybe. A benchmark will definitely help to solve this dilemma.
from event-dispatcher.
https://gist.github.com/SamMousa/22dfaf40b89d21748afdd238de2fd8a8
from event-dispatcher.
What if we add another argument
public function attach(string $eventName, callable $listener): void
{
$this->listeners[$eventName][] = $listener;
}
//use
$provider->attach(Event::class, $listener);
from event-dispatcher.
This provider / issue is about using reflection.
We can definitely add another function / create another provider, but it is not related to this issue.
from event-dispatcher.
@KpuTuK that was how it was done initially but since handler has to type-hint for event anyway, why not to re-use this information?
from event-dispatcher.
@SamMousa я не совсем понял. плохой английский.
from event-dispatcher.
Sorry @KpuTuK, my Russian is probably much worse than your English ;-)
from event-dispatcher.
@KpuTuK изначально так и было сделано. Но раз мы указываем интерфейс события в аргументе хендлера, то есть ли смысл делать это два раза?
// above is translation of my comment into Russian
from event-dispatcher.
Related Issues (16)
- Consider being able to explicitly register for a given event name HOT 5
- Document composite dispatcher
- Why does attach function of Provider become protected? HOT 19
- Consider introducing cache HOT 2
- Why cloning ListenerCollection every time when adding a new listener? HOT 3
- Consider adding EventTrait HOT 1
- Typehint callable in `getParameterType()`
- Styling HOT 2
- getListenersForEvent: current implementation vs instanceof HOT 2
- possible bug with PHP8 and Union type-hint HOT 1
- Improve exception message in `ListenerCollection::add()` HOT 1
- Consider introducing deferred event provider HOT 15
- Add Priorities on events' handlers HOT 7
- Rename ListenerCollection::add HOT 2
- Allow use only class and interface as listener parameter
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from event-dispatcher.