Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vizz.async-client

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vizz.async-client

NodeJS library to send or receive async messages (independently of the technology (redis, activemq))

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
175
increased by483.33%
Maintainers
1
Weekly downloads
 
Created
Source

Publish / Subscribe Client (Support to generators)

Now only support to Redis. In the future we may add support for the AMQP protocol.

Install

npm install --save vizz.async-client-nodejs

Use

You have examples in examples folder. To execute example: npm run example

Code:

'use strict';
const CHANNEL = 'myChannel';

function* iter(number) {
    for (var i = 0; i < number; i++) {
        yield i;
    }
}

function* gen(number) {
    for (var val of iter(number)) {
        console.log(val);
    }
}

var AsyncClient = require('../index');

var asyncClientPublish = new AsyncClient(AsyncClient.REDIS, {
    host: 'localhost' // redis url
});
var asyncClientSubscriber = new AsyncClient(AsyncClient.REDIS, {
    host: 'localhost'// redis url
});

var channelSubscribe = asyncClientSubscriber.toChannel(CHANNEL);
channelSubscribe.on('message', function*(channel, message) {
                                   console.log('Message received: ' + message);
                                   yield gen(message);
                                   console.log('Message completed');
});
channelSubscribe.subscribe();

asyncClientPublish.toChannel(CHANNEL).emit(2);
asyncClientPublish.toChannel(CHANNEL).emit(5);

FAQs

Package last updated on 06 Sep 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc