Namespace: PubSub

PubSub

A hierarchical publish and subscribe namespace. Channels consist of strings, sub-channels are separated with a period ('.'). Publishing to a target channel will propagate the message breadth first from the root of the hierarchy to the target channel, then from the target channel to all its existing sub-channels.
Ex.

    Hierarchy:

        layer -> server -> abc28d05-9b9d-4e03-9f53-9f88cf7078c7
                           fb943cca-cac3-4bbf-ba03-91a1559fee28
                           67fd55b5-dc3a-40cf-8adc-9e634b82d474
                 client -> 3392103f-7f50-4422-ae59-2c2c0971951f
                           7bc33c81-c347-4bea-9cfb-c22328bcb648

    Publishing to 'layer.server' will publish:

        From root to target:

            1) layer

    From target to all sub-channels:

            2) layer.server
            3) layer.server.abc28d05-9b9d-4e03-9f53-9f88cf7078c7
            4) layer.server.fb943cca-cac3-4bbf-ba03-91a1559fee28
            5) layer.server.67fd55b5-dc3a-40cf-8adc-9e634b82d474

    Publishing to 'layer.client.3392103f-7f50-4422-ae59-2c2c0971951f' will publish:

        From root to target:

            1) layer
            2) layer.client

        From target to all sub-channels:

            3) layer.client.3392103f-7f50-4422-ae59-2c2c0971951f

Methods

staticPubSub.publish(channelPath, message)

Publish a message to a channel path. Publishing to a target channel will propagate the message breadth first from the root of the hierarchy to the target channel, then from the target channel to all existing sub-channels
Name Type Description
channelPath string A '.' delimited channel path.
message * The messsage to be published.

staticPubSub.subscribe(channelPath, subscriber)

Subscribe a listener function to the specific channel path.
Name Type Description
channelPath string A '.' delimited channel path.
subscriber function The subscriber function associated with the provided path.