Socket
Book a DemoInstallSign in
Socket

js-pubsub

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-pubsub

A simple Pub/Sub implementation for JavaScript that also contains an ask/tell paradigm.

2.1.5
latest
Source
npmnpm
Version published
Weekly downloads
2
-50%
Maintainers
1
Weekly downloads
 
Created
Source

PubSub

Build Codecov npm version

A simple Pub/Sub implementation for JavaScript that also contains an ask/tell paradigm.

Here is some example usage from some of the tests:

import { Pubsub } from 'js-pubsub'

var pubsub = new Pubsub();

it("publish to same topic receives callback with correct argument", () => {
    //Arrange
    var argResult;
    pubsub.subscribe({ toTopic: "arg test", withCallback: result => argResult = result });

    //Act
    pubsub.publish({ toTopic: "arg test", withData: "it worked" });

    //Assert
    expect(argResult).to.equal("it worked");
});

it("should allow tellers to answer questions using parameters for context", () => {
    //Arrange
    //Act
    pubsub.answerFor("topic", p1 => `answer${p1}`);

    //Assert
    expect(pubsub.askFor("topic", 1)).to.equal("answer1");
});

Keywords

pubsub

FAQs

Package last updated on 24 Nov 2020

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.