vital.vim icon indicating copy to clipboard operation
vital.vim copied to clipboard

add support for CancellationTokenSource and CancellationToken

Open prabirshrestha opened this issue 6 years ago • 4 comments

CancellationTokenSource examples: https://docs.microsoft.com/en-us/dotnet/standard/threading/cancellation-in-managed-threads https://github.com/axios/axios

Abort Controllers: https://developer.mozilla.org/en-US/docs/Web/API/AbortController/AbortController

prabirshrestha avatar Dec 25 '18 01:12 prabirshrestha

Here you are. https://github.com/lambdalisue/vital-Whisky/tree/master/autoload/vital/vital/Async

lambdalisue avatar Dec 25 '18 04:12 lambdalisue

@lambdalisue Would it be possible to get those merged in this repo?

prabirshrestha avatar Dec 25 '18 04:12 prabirshrestha

Yes but not yet because vital.vim does not run tests on Neovim yet.

lambdalisue avatar Dec 25 '18 05:12 lambdalisue

I'm currently using callbag.vim and cancellation is now very easy with takeUntil. The following will start logging when the user enters insert mode and automatically stops logging when the user leaves the insert mode.

     call callbag#pipe(
        \ callbag#fromEvent('TextChangedI'),
        \ callbag#takeUntil(
        \   callbag#fromEvent('InsertLeave'),
        \ ),
        \ callbag#debounceTime(250),
        \ callbag#subscribe({
        \   'next': {x->s:log('next')},
        \   'error': {x->s:log('error')},
        \   'complete': {->s:log('complete')},
        \ }),
        \ )

Feel free to close the issue.

prabirshrestha avatar Dec 31 '19 20:12 prabirshrestha