vertx3-eventbus-rx-client
RxJS powered Event Bus client for Vert.x 3.
This library:
- Offers an API similar to Rxified server counterpart.
- Includes Typescript definitions and provides interfaces for data models (Message, CloseEvent etc.).
- Wraps the official client without side effects, thus can be used together with the official client by providing it as a delegate to the constructor.
- Helps to prevent memory leaks by unsubscribing on disconnect or close (or after receiving a reply in case of rxSend).
- Does not provide features like send with timeout, auto-resubscription etc. because these are trivial to implement with rxjs operators and subjects.
Getting Started
Installation
install using npm:
npm install vertx3-eventbus-rx-client --save
Peer Dependencies
Make sure you have RxJS 5 and official event bus client (version 3.4.x) as dependencies in your project, or install them as follows:
npm install vertx3-eventbus-client@3.4.2 --save
npm install rxjs --save
Usage
import as ES module:
; const eb = EventBus;
import as CommonJS module:
const RxEB = ; const eb = RxEBEventBus;
API
Creating an instance:
// by using factory methodconst eb = EventBus; // by wrapping an existing non-Rxified eventbus objectconst eb = delegateEB;
EventBus state:
let ebState; // get current stateebState = ebstate; // get current state and future changesebstate$;
Sending messages:
const message = {};// send a messageeb; // send and expect a replyeb;
Message consumer:
// register consumerconst subscription = eb; // un-register consumersubscription;
Getting close event:
// get close eventebcloseEvent; // close event is null until State is CLOSED ebstate$;
Full API documentation can be found HERE.
Testing
Run unit tests with:
npm run test
End-to-end tests should be run against the Test Server. Once it is up and running, start the tests with this command:
npm run e2e
License
This project is licensed under the MIT License - see the LICENSE file for details