Skip to content

Instantly share code, notes, and snippets.

@prabirshrestha
Last active October 22, 2016 17:03
Show Gist options
  • Save prabirshrestha/1c9e884ad13bd83c1ad7 to your computer and use it in GitHub Desktop.
Save prabirshrestha/1c9e884ad13bd83c1ad7 to your computer and use it in GitHub Desktop.
async vim with channel
function! s:Handler(handle, msg)
echom a:handle
echom a:msg
endfunction
let handle = ch_open('localhost:8000', {'mode': 'json'})
call ch_sendexpr(handle, 'hello', function('s:Handler'))
var net = require('net');
net.createServer(function(socket){
socket.on('data', function(data){
var request = JSON.parse(data);
console.log('received', request);
setTimeout(function () {
var response = [
request[0],
request[1]
];
console.log('sending', response);
socket.write(JSON.stringify(response));
}, 2000);
});
}).listen(8000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment