Callback nREPL API

Pass a callback to call to have it invoked for each response message.
This might one day become asynchronous in certain circumstances, but
don't count it.
This commit is contained in:
Tim Pope 2014-01-09 01:00:45 -05:00
parent 382869c6c7
commit 52758fd4ea

View File

@ -231,9 +231,14 @@ function! s:nrepl_prepare(payload) dict abort
return payload return payload
endfunction endfunction
function! s:nrepl_call(payload) dict abort function! s:nrepl_call(payload, ...) dict abort
let payload = self.prepare(a:payload) let payload = self.prepare(a:payload)
return filter(self.dispatch('call', nrepl#fireplace_connection#bencode(payload)), 'v:val.id == payload.id') let response = filter(self.dispatch('call', nrepl#fireplace_connection#bencode(payload)), 'v:val.id == payload.id')
if a:0
call map(response, 'call(a:1, v:val)')
else
return response
endif
endfunction endfunction
let s:nrepl = { let s:nrepl = {