Last active
November 16, 2017 00:32
-
-
Save andreaslillebo/8ff8d7c022058f5ca21b2935f69a445f to your computer and use it in GitHub Desktop.
Client-side connection to ActionCable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
