npm

@pubsub-a/micro
TypeScript icon, indicating that this package has built-in type declarations

0.9.6 • Public • Published

PubSub/A Reference Implementation

This is the reference implementation of the PubSub/A interface proposal. The implementation is written in TypeScript but can be consumed from any JavaScript code.

While PubSub/A is designed to work over the network, this reference implementation only works locally. Subscriptions are only share among the same instance of the PubSubMicro instance.

import { PubSubMicro as PubSub } from "@pubsub-a/micro"

const pubsub = new PubSub();
pubsub.start()
    .then(function() {
        return pubsub.channel('myChannel');
    }).then(function(channel) {
        channel.subscribe('myTopic', function(arg) {
            console.log('received arg: ', arg);
        });
        channel.publish('myTopic', { foo: 'bar' });
    });
});

See the PubSub/A interface definition for in-depth syntax overview.

Readme

Keywords

none

Package Sidebar

Install

npm i @pubsub-a/micro

Weekly Downloads

1

Version

0.9.6

License

MIT

Unpacked Size

36.6 kB

Total Files

30

Last publish

Collaborators

  • dynalon