@signalwire/js
Version:
46 lines • 1.33 kB
TypeScript
import type { PubSubContract, ConsumerContract, UserOptions, PubSub as PubSubNamespace } from '@signalwire/core';
export interface ClientApiEvents extends PubSubNamespace.BasePubSubApiEvents {
}
/** @ignore */
export interface ClientFullState extends Client {
}
export interface Client extends PubSubContract, Omit<ConsumerContract<ClientApiEvents, ClientFullState>, 'subscribe'> {
}
/** @ignore */
export interface ClientOptions extends UserOptions {
}
/**
* You can use the Client object to build a messaging system into the browser.
*
* Example usage:
*
* ```js
* import { PubSub } from '@signalwire/js'
*
* const pubSubClient = new PubSub.Client({
* token: '<your pubSub token>', // get this from the REST APIs
* })
*
* await pubSubClient.subscribe([ 'mychannel1', 'mychannel2' ])
*
* pubSubClient.on('message', (message) => {
* console.log("Received", message.content,
* "on", message.channel,
* "at", message.publishedAt)
* })
*
* await pubSubClient.publish({
* channel: 'mychannel1',
* content: 'hello world'
* })
* ```
*
* ## Events
*
* Please see {@link ClientApiEvents} for the list of events emitted by a pubSub
* Client object.
*/
export declare const Client: {
new (pubSubOptions: ClientOptions): Client;
};
//# sourceMappingURL=Client.d.ts.map