Pubsub
Interacts with Atlassian Frontend PubSub service to receive pubsub events.
yarn add @atlaskit/pubsub
7.0.0
Major Changes
-
#117363
10a0f7f6c2027
- This package'speerDependencies
have been adjusted forreact
and/orreact-dom
to reflect the status of only supporting React 18 going forward. No explicit breaking change to React support has been made in this release, but this is to signify going forward, breaking changes for React 16 or React 17 may come via non-major semver releases.Please refer this community post for more details: https://community.developer.atlassian.com/t/rfc-78-dropping-support-for-react-16-and-rendering-in-a-react-18-concurrent-root-in-jira-and-confluence/87026
Note: This component is designed for internal Atlassian development.
External contributors will be able to use this component but will not be able to submit issues.
This provides components for receiving events from the PubSub service.
Usage
import { PubSubClient } from '@atlassian/pubsub';
### Using the component as a component developer
class Component {
private pubSubClient: PubSubClient;
constructor(pubSubClient: PubSubClient) {
this.pubSubClient = pubSubClient;
this.subscribeToPubSubEvents();
}
private subscribeToPubSubEvents() {
this.pubSubClient.on('avi:jira:updated:issue', this.onIssueUpdate);
}
onIssueUpdate = (event: string, payload) => {
};
};
Using the component as a product developer
import { default as Client } from '@atlassian/pubsub';
const pubSubClient = new Client({
product: 'STRIDE',
url: 'https://api-private.atlassian.com/pubsub',
});
// Call join to join channels for the given context, for example for current conversations in Stride
pubSubClient.join([
'ari:cloud:banana:f7ebe2c0-0309-4687-b913-41d422f2110b:conversation/b17d8707-db6e-436e-95b9-102dd1986293',
]);
// Call leave to leave channels (when closing a conversation for example)
pubSubClient.leave([
'ari:cloud:banana:f7ebe2c0-0309-4687-b913-41d422f2110b:conversation/b17d8707-db6e-436e-95b9-102dd1986293',
]);
};
You should then make the pubSubClient available to components.
Client
Config
Events
Enabling the Atlassian PubSub (aka APS) protocol
To enable the APS protocol in your client, simply pass "true" to the "apsProtocol.enabled" field in the constructor config. You can also specify a custom URL for the APS service via the "apsProtocol.url" field, although it is recommended that the default URL should be used in most cases.
return new Client({
product: 'STRIDE',
url: 'https://api-private.atlassian.com/pubsub',
apsProtocol: {
enabled: true,
url: '{optionalUrl}'
},
});