Last active
February 26, 2020 10:18
-
-
Save jwulf/d10859a9b3daa30ed13e8bdc11272533 to your computer and use it in GitHub Desktop.
Example code from the article https://www.joshwulf.com/blog/2020/02/shun-the-mutant/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const GRPCConnection = gRPC => 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