Reconnecting
To reconnect, just call .open() on the channel. All listeners, options, and keys remain intact.
import { connect } from 'itty-sockets'
const channel = connect('my-channel', { announce: true })
.on('message', console.log)
// reconnect every second if disconnected
setInterval(channel.open, 1000)Note: There's no penalty for calling
.open() multiple times, or on a connection that is already open.Next: TypeScript — type your listeners, sends, and connections.