@tshio/command-bus
v1.0.4
Published
Command Bus
Downloads
265
Readme
Command Bus
Non-blocking Command Bus library for Node.js.
This is a 100% JavaScript library, with TypeScript definition, with the Promise API.
Installing
$ npm install @tshio/command-bus
or
yarn add @tshio/command-bus
Usage
// CommonJS
const { Command, CommandBus, CommandHandler } = require('@tshio/command-bus');
// ES Module
import { Command, CommandBus, CommandHandler } from '@tshio/command-bus';
class TestHandler implements CommandHandler<Command<string>> {
public commandType: string = "test-type";
async execute(command: Command<string>) {
return `handler-message ${command.payload}`;
}
}
const bus = new CommandBus([new TestHandler()]);
const testCommand: Command<string> = {
payload: "payload-data",
type: "test-type",
};
const result = await bus.execute(testCommand);
console.log(result);
// => "handler-message payload-data"
License
This project is licensed under the terms of the MIT license.
About us:
The Software House