Skip to content

Instantly share code, notes, and snippets.

@sesgoe
sesgoe / 01_scripts_and_styles.js
Last active May 7, 2024 07:32
Retool Realtime WebSocket
const webSocket = new WebSocket('wss://echo.websocket.org');
//Event listeners are the pillars upon which WebSockets are built. This event fires when the WebSocket is considered 'OPEN',
//which means that it has connected successfully.
webSocket.addEventListener('open', function(event) {
console.log('websocket connected successfully') //log this into the browser console so we can check if the websocket connected
});
//This is a global reference to the websocket that we created. We need this because otherwise multiple JS