@bunchtogether/braid-client
v1.2.13
Published
[![CircleCI](https://circleci.com/gh/bunchtogether/braid-client-js.svg?style=svg)](https://circleci.com/gh/bunchtogether/braid-client-js) [![npm version](https://badge.fury.io/js/%40bunchtogether%2Fbraid-client.svg)](http://badge.fury.io/js/%40bunchtogeth
Downloads
112
Readme
Braid Client
WebSocket-based key-value synchronization.
See also:
API
Table of Contents
- ConnectionError
- CredentialsError
- SubscribeError
- EventSubscribeError
- PublishError
- ServerRequestError
- Client
ConnectionError
Extends Error
Class representing a connection error
Parameters
message
string
CredentialsError
Extends Error
Class representing a credentials error
Parameters
SubscribeError
Extends Error
Class representing a subscribe error
Parameters
EventSubscribeError
Extends Error
Class representing an event subscribe error
Parameters
PublishError
Extends Error
Class representing an publishing error
Parameters
ServerRequestError
Extends Error
Class representing an error that interupts a pending server request, for example if a connection closes prematurely
Parameters
Client
Extends EventEmitter
Class representing a Braid Client
data
Primary data object. Like a native JS Map but with 'set' and 'delete' events.
setReconnectHandler
Set the reconnect handler. The handler determines if the reconnect should continue.
Parameters
Returns void
open
Connects to a server.
Parameters
Returns Promise<void>
close
Close connection to server.
Parameters
code
number? Websocket close reason code to send to the serverreason
string? Websocket close reason to send to the server
Returns Promise<void>
sendCredentials
Send credentials to a server with an open connection.
Parameters
credentials
Object? Credentials to send
Returns Promise<void>
subscribe
Subscribe to updates on a key.
Parameters
key
string Key to request updates on
Returns Promise<void>
sendSubscribeRequest
Send subscribe request to server
Parameters
key
string Key to request updates on
Returns Promise<void>
unsubscribe
Unsubscribe from updates on a key. If the callback parameter is not provided, all callbacks are unsubscribed.
Parameters
key
string Key to stop updates on
Returns Promise<void>
addServerEventListener
Subscribe to a server event
Parameters
name
string Name of the event to listen forcallback
function (): void?
Returns Promise<void>
sendEventSubscribeRequest
Send event subscribe request to server
Parameters
name
string Name of the event to listen for
Returns Promise<void>
removeServerEventListener
Unsubscribe from a server event. If the callback parameter is not provided, all callbacks are unsubscribed.
Parameters
name
string Name of the event to stop listeningcallback
function (any): void?
Returns Promise<void>
startPublishing
Start publishing to a receiver
Parameters
name
string Name of the receiver to start publishing to
Returns Promise<void>
publish
Publish message to a receiver
Parameters
name
string Name of the receivermessage
any Value to publish, should not contain undefined values
Returns Promise<void>
sendPublishRequest
Send event subscribe request to server
Parameters
name
string Name of the event to listen for
Returns Promise<void>
stopPublishing
Stop publishing to a receiver.
Parameters
name
string Name of the receiver to stop publishing to
Returns Promise<void>