innmind/command-bus

此包已被弃用且不再维护。未建议替代包。

命令总线库

4.2.0 2021-02-14 15:00 UTC

This package is auto-updated.

Last update: 2022-12-12 08:11:44 UTC


README

Build Status codecov Type Coverage

一个简单的库,用于将命令路由到其处理器,接口允许您组合总线以添加功能。每个处理器都必须是一个 可调用 对象。

安装

composer require innmind/command-bus

示例

use function Innmind\CommandBus\bootstrap;
use Innmind\Immutable\Map;

class MyCommand {}

$echo = function(MyCommand $command) {
    echo 'foo';
};

$handle = bootstrap()['bus'](
    Map::of('string', 'callable')
        (MyCommand::class, $echo)
);

$handle(new MyCommand); //prints 'foo' and return null;