Skip to content

Instantly share code, notes, and snippets.

@didierfranc
Created December 18, 2017 21:00
Show Gist options
  • Save didierfranc/4ae4fb91df6dee4d9783724b7944cb5f to your computer and use it in GitHub Desktop.
Save didierfranc/4ae4fb91df6dee4d9783724b7944cb5f to your computer and use it in GitHub Desktop.
// Legacy code
const messages = []
const getMessages = async () => {
messages = await fetch('/messages').then(r => r.json())
}
// Make it live
const ws = new WebSocket(`wss://socket.cool/${app}/${channel}/${uid}`)
ws.onmessage = getMessages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment