Skip to content

Instantly share code, notes, and snippets.

@andreaslillebo
Last active November 16, 2017 00:32
Show Gist options
  • Select an option

  • Save andreaslillebo/8ff8d7c022058f5ca21b2935f69a445f to your computer and use it in GitHub Desktop.

Select an option

Save andreaslillebo/8ff8d7c022058f5ca21b2935f69a445f to your computer and use it in GitHub Desktop.
Client-side connection to ActionCable
console.log('About to subscribe');
window.App.mySubscription = window.App.cable.subscriptions.create({
channel: 'MyChannel',
uuid,
}, {
connected: () => {
// Called when the subscription is ready for use on the server
console.log('connected');
// some other code that needs to be called here.
},
disconnected: () => {
// Called when the subscription has been terminated by the server
console.log('disconnected');
},
received: () => {
// Called when there's incoming data on the websocket for this channel.
console.log('received');
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment