Namespace

pubsub

kiss.pubsub

A simple PubSub

  1. subscribe a function to a channel:
let subscriptionId = kiss.pubsub.subscribe("MY_CHANNEL_NAME", (messageData) => { console.log(messageData) })
  1. publish a message on a channel:
kiss.pubsub.publish("MY_CHANNEL_NAME", {foo: "bar"})
  1. unsubscribe a function:
kiss.pubsub.unsubscribe(subscriptionId)
  1. list all active subscriptions
kiss.pubsub.list()

View Source client/core/modules/pubsub.js, line 28

Methods

# static get(subscriptionId) → {function}

Get a subscription by id.

Mainly used for debug purpose, when you need to check which function is registered in the pubsub.

Parameters:
Name Type Description
subscriptionId string

The id of the subscription to retrieve

View Source client/core/modules/pubsub.js, line 129

The subscribed function

function

# static getCount() → {number}

Return the number of subscriptions.

Mainly used for debugging (useful to track memory leaks).

View Source client/core/modules/pubsub.js, line 112

number

# static list(showFunctionopt)

List all the subscriptions in the console.

Mainly used for debug purpose, when you need an overview of subscriptions.

Parameters:
Name Type Attributes Description
showFunction boolean <optional>

If true, show the subscribed function

View Source client/core/modules/pubsub.js, line 154

# static publish(channel, messageDataopt)

Publish a message on a specific channel

Parameters:
Name Type Attributes Description
channel string

The channel name

messageData object <optional>

The data published into the channel

View Source client/core/modules/pubsub.js, line 39

# static subscribe(channel, fn, descriptionopt) → {string}

Subscribe a function to a channel

Parameters:
Name Type Attributes Description
channel string

The channel name

fn function

The function to subscribe to the channel

description string <optional>

Optional description of the subscription

View Source client/core/modules/pubsub.js, line 70

The subscription id

string

# static unsubscribe(subscriptionId)

Unsubscribe a function from the pubsub

Parameters:
Name Type Description
subscriptionId string

The id of the subscription to remove

View Source client/core/modules/pubsub.js, line 89