Socket
Book a DemoInstallSign in
Socket

@tshio/command-bus

Package Overview
Dependencies
Maintainers
6
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tshio/command-bus

Command Bus

latest
Source
npmnpm
Version
1.0.4
Version published
Maintainers
6
Created
Source

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

tsh.png

FAQs

Package last updated on 04 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts