Skip to main content

API reference

ActionCable

MethodDescription
createConsumer(url, headers?)Create a new consumer and connect
getOrCreateConsumer(url, headers?)Reuse existing consumer or create new one
disconnectConsumer(url)Disconnect and remove consumer from cache
startDebugging()Enable debug logging
stopDebugging()Disable debug logging

Consumer Instance

MethodDescription
subscriptions.create(params)Create a channel subscription
connection.isOpen()Check if connected
connection.isActive()Check if connected or connecting
disconnect()Disconnect from server

Cable

MethodDescription
setChannel(name, subscription)Register a channel
channel(name)Get channel by name

Channel

MethodDescription
on(event, callback)Subscribe to events: received, connected, disconnected, rejected, error
on('connected', cb)cb({ reconnected }) - reconnected is true when the subscription came back after a dropped connection
on('disconnected', cb)cb({ willAttemptReconnect, code, reason }) - reason is where React Native reports why the socket dropped
on('error', cb)cb({ message, event }) - a readable message, with the original platform event attached
removeListener(event, callback)Remove event listener
perform(action, data)Send message to server
unsubscribe()Unsubscribe from channel