Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Last active June 22, 2021 14:18
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 velotiotech/aa5730fba5f35fa78327ad61929c7321 to your computer and use it in GitHub Desktop.
Save velotiotech/aa5730fba5f35fa78327ad61929c7321 to your computer and use it in GitHub Desktop.
window.addEventListener('load', () => {
// ### ABOVE CODE HERE ###
const connectBtn = document.getElementById('connect-btn');
connectBtn.addEventListener('click', () => {
if (provider.shouldConnect) {
provider.disconnect();
connectBtn.textContent = 'Connect'
} else {
provider.connect();
connectBtn.textContent = 'Disconnect'
}
});
window.example = { provider, ydoc, type, binding, Y }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment