Skip to content

Instantly share code, notes, and snippets.

@jwulf
Last active February 26, 2020 10:19
Show Gist options
  • Save jwulf/269745c95b98c0308b95c472066c24c0 to your computer and use it in GitHub Desktop.
Save jwulf/269745c95b98c0308b95c472066c24c0 to your computer and use it in GitHub Desktop.
const GRPCConnection = url => {
let connected = false
const _connection = gRPC(url)
_connection.on('connect', () => (connected = true))
_connection.on('disconnect', () => (connected = false))
return {
getIsConnected(): connected,
connect: () => connected || _connection.connect()
send: command => _connection.send(command)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment