library for rails action cable
npm install @sequenia/socket-action-cable> library for rails action cable
 
``bash`
npm install --save @sequenia/socket-action-cable
`jsx
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) => { ... })
``
MIT © sequenia