2.0.1 • Published 3 years ago

@layerr/bus v2.0.1

Weekly downloads
36
License
MIT
Repository
-
Last release
3 years ago

BUS

BusLayerr is a library to create an in-memory message bus layer in your application. It is completely configurable using middlewares. Just imagine your next message :bus:

It uses RxJS as internal engine. If you are not comfortable with it, don't worry, you can use promise-like async code.

Installation

Use npm package manager to install it.

npm install @layerr/core @layerr/bus rxjs reflect-metadata

Use yarn package manager to install it.

yarn add @layerr/core @layerr/bus rxjs reflect-metadata

Documentation

Documentation

Quick usage

BusLayerr allows to create a generic bus to send any type of message and handling them with functions.

const mapping = [
  { 
    message: 'message1', 
    handler: (message: string) => {
      // message === 'message1'
    } 
  },
  { 
    message: 'message2', 
    handler: (message: string) => {
      // message === 'message2'
    } 
  },
];

const messageBus = GeneralPurposeBusFactory.Create(mapping);

Handle a message by calling the method to send over the bus:

messageBus.handle('message1');

// It will call the handler for message1.

...

messageBus.handle('message2');

// It will call the handler for message2.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

2.0.1

3 years ago

1.4.0

3 years ago

2.0.0

3 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago