Skip to content

Instantly share code, notes, and snippets.

@tyru
Created February 10, 2018 07:24
Show Gist options
  • Select an option

  • Save tyru/60d4056b1edc0fd2c81d336ce0ce70be to your computer and use it in GitHub Desktop.

Select an option

Save tyru/60d4056b1edc0fd2c81d336ce0ce70be to your computer and use it in GitHub Desktop.
Deferred object using Vital.Async.Promise
let s:V = vital#vital#new()
let s:P = s:V.import('Async.Promise')
unlet s:V
function! s:_defer() abort
let d = {}
let d.promise = s:P.new({resolve, reject -> extend(d, {
\ 'resolve': {-> call(resolve, a:000)},
\ 'reject': {-> call(reject, a:000)},
\})})
return d
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment