# Pub Sub

**Kind**: module | **Library**: @interopio/desktop | **Access**: `io.bus`

**Source**: https://docs.interop.io/desktop/reference/javascript/pub sub/index.html

The Pub/Sub API enables applications to:

- publish messages on a specific topic;
- subscribe for messages on a specific topic;

When an application publishes a message on a specific topic, the Pub/Sub API delivers it to other applications that have subscribed to that topic.

The "raw Pub/Sub" support allows io.Connect Desktop to work with applications already using a Pub/Sub technology.
Before writing new Pub/Sub based code, please consider the higher level Interop services provided by io.Connect Destop: Request/Response, Streaming, Discovery and Shared Contexts.
Utilizing these services, instead of creating them from scratch, can save you time and also provide you with a more robust service that can interact with applications by different dev teams and vendors.

The Pub/Sub API is accessible through the `io.bus` object.

## Interfaces

- [API](https://docs.interop.io/desktop/reference/javascript/pub%20sub/api/index.md)
- [MessageOptions](https://docs.interop.io/desktop/reference/javascript/pub%20sub/messageoptions/index.md): If `routingKey` is provided when publishing a message, the message will be delivered only to peers that have provided the same routing key
- [Subscription](https://docs.interop.io/desktop/reference/javascript/pub%20sub/subscription/index.md): Subscription object that can be used to unsubscribe from a topic and stop receiving data.
