Quick start
1. Create a consumer
import { ActionCable, Cable } from '@kesha-antonov/react-native-action-cable'
const actionCable = ActionCable.createConsumer('ws://localhost:3000/cable')
const cable = new Cable({})
2. Subscribe to a channel
const channel = cable.setChannel(
'ChatChannel',
actionCable.subscriptions.create({
channel: 'ChatChannel',
roomId: 1
})
)
channel
.on('received', (data) => console.log('Received:', data))
.on('connected', () => console.log('Connected!'))
.on('disconnected', () => console.log('Disconnected'))
3. Send messages
channel.perform('send_message', { text: 'Hello!' })
4. Cleanup
channel.unsubscribe()