34 lines
1.1 KiB
PHP
34 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace NoccyLabs\React\CommandBus;
|
|
use Evenement\EventEmitterInterface;
|
|
use React\Promise\PromiseInterface;
|
|
|
|
interface CommandBusInterface extends EventEmitterInterface
|
|
{
|
|
/** @var string Emitted to distribrute notifications */
|
|
const EVENT_NOTIFY = "notify";
|
|
|
|
/**
|
|
* Execute a command on the command bus, and return a promise that will be
|
|
* resolved once the command has been handled.
|
|
*
|
|
* @param string $command The name of the command to execute
|
|
* @param array $context Data to pass in the call context
|
|
* @®eturn PromiseInterface A promise that will be resolved with the result
|
|
*/
|
|
public function execute(string $command, array $context): PromiseInterface;
|
|
|
|
/**
|
|
* Notify all connected clients to emit the notify event, and also be
|
|
* emitted locally. These messages are unsolicited, and can not be
|
|
* responded to. They are fire-and-forget.
|
|
*
|
|
* @param string $event The application-specific event name
|
|
* @param array $data Event-specific data
|
|
* @return void
|
|
*/
|
|
public function notify(string $event, array $data): void;
|
|
}
|
|
|