@sequenia/socket-action-cable
v1.0.0
Published
library for rails action cable
Downloads
1
Keywords
Readme
@sequenia/socket-action-cable
library for rails action cable
Install
npm install --save @sequenia/socket-action-cable
Usage
import ActionCable from '@sequenia/socket-action-cable'
/* create socket connection */
const url = "wss://url-path-to-somewhere";
const ActionCableInstance = new ActionCable(url)
/* subscribe to channel: channell name, params and onMessage channel callback function */
ActionCableInstance.subscribe("ExampleChannel", {foo: "bar", bar: "buzz"}, message => message)
/* unsubscribe */
ActionCableInstance.unsubscribe("ExampleChannel")
/* get readyState of socket connection */
const readyState = ActionCableInstance.readyState
/* get buffered amount of socket connection */
const bufferedAmount = ActionCableInstance.bufferedAmount
/* close connection */
ActionCableInstance.close()
/* onError socket connection callback */
ActionCableInstance.onErrorCallback((event) => { ... })
/* onClose socket connection callback */
ActionCableInstance.onClose((event) => { ... })
License
MIT © sequenia