-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add documentation for QueryBus #7
Comments
Yeah please, im curious 😃 |
It's very similar to usage of command bus. The only difference is that handler returns result and that it's registered with messageBus:
queryBus:
services:
- class: MyCoolHandler
tags: [queryBus.handler] class MyCoolQuery {}
class MyCoolQueryHandler
{
public function handle(MyCoolQuery $query): string
{
return 'foo';
}
}
/** @var eGen\MessageBus\Bus\QueryBus() $queryBus */
$result = $queryBus->handle(new MyCoolQuery());
// prints "foo"
print_r($result); |
Hi, i have found this package I did not try it yet, but i like the usage What i was excited about was, if it would be possible to pass typehint there Right now i have to do this: /** @var MyClass $queryResult */
$queryResult = $queryBus->handle($query); But as i mentioned, i did not test it, so i do not even know if it is allowed to typehint references in php. |
Can you post snippet of what you mean? I don't really like the idea of passing reference to handle method instead of using return value. References in PHP make code hard to read and error-prone. |
Yeah, i was not sure about it, thank you for making it clear to me 👍 I must agree with you, for readability your approach is much better. |
No description provided.
The text was updated successfully, but these errors were encountered: