1.0.4 • Published 2 years ago

@tshio/command-bus v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Command Bus

npm version

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

license

This project is licensed under the terms of the MIT license.

About us:

The Software House

1.0.4

2 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

0.0.1

3 years ago