Skip to content

Instantly share code, notes, and snippets.

@esparkman
Created November 29, 2017 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esparkman/c4e6b96d51e7e7a729674a8c7b492afa to your computer and use it in GitHub Desktop.
Save esparkman/c4e6b96d51e7e7a729674a8c7b492afa to your computer and use it in GitHub Desktop.
App.products = App.cable.subscriptions.create("ProductsChannel", {
connected: function() {
// Called when the subscription is ready for use on the server
},
disconnected: function() {
// Called when the subscription has been terminated by the server
},
received: function(data) {
// Called when there's incoming data on the websocket for this channel
document.getElementsByTagName("main")[0].innerHTML = data.html
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment