2.1.5 • Published 3 years ago

js-pubsub v2.1.5

Weekly downloads
2
License
GPL-3.0
Repository
github
Last release
3 years ago

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");
});
2.1.5

3 years ago

2.1.4

3 years ago

2.1.3

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.7

6 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago