Skip to content

pubsub-a/micro

Repository files navigation

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.

About

Reference in-memory PubSub/A implementation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published