npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vertx3-eventbus-rx-client

v0.4.2

Published

RxJS powered Event Bus client for Vert.x 3

Downloads

43

Readme

Build Status Coverage Status npm version MIT license

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 [email protected] --save
npm install rxjs --save

Usage

import as ES module:

import { EventBus } from 'vertx3-eventbus-rx-client';

const eb = EventBus.create('server-address');

import as CommonJS module:

const RxEB = require('vertx3-eventbus-rx-client');

const eb = RxEB.EventBus.create('server-address');

API

Creating an instance:

// by using factory method
const eb = EventBus.create('server-url');

// by wrapping an existing non-Rxified eventbus object
const eb = new EventBus(delegateEB);

EventBus state:

let ebState;

// get current state
ebState = eb.state;

// get current state and future changes
eb.state$.subscribe(
  state => {
    ebState = state;
  }
);

Sending messages:

const message = {};
// send a message
eb.send('address', message);

// send and expect a reply
eb.rxSend('address', message).subscribe(
  reply => {
    // received a reply
  },
  error => {
    // received an error
  }
);

Message consumer:


// register consumer
const subscription =  eb.rxConsumer('address').subscribe(
  message => {
    // received a message
  }
);

// un-register consumer
subscription.unsubscribe();

Getting close event:


// get close event
eb.closeEvent;

// close event is null until State is CLOSED 
eb.state$.subscribe(
  state => {
    if (state !== State.CLOSED) {
      console.log(eb.closeEvent); // null
    } else {
      console.log(eb.closeEvent); // NOT null. Refer to CloseEvent docs on the link below.
    }
  }
);

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