doc: mention that defer_fn applies schedule_wrap (#12601)

This commit is contained in:
Christian Clason 2020-07-07 10:55:40 +02:00 committed by GitHub
parent e49fc4ba1f
commit 91572ddad1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -415,6 +415,8 @@ To avoid the error use |vim.schedule_wrap()| to defer the callback: >
vim.api.nvim_command('echomsg "test"')
end))
(For one-shot timers, see |vim.defer_fn()|, which automatically adds the wrapping.)
Example: repeating timer
1. Save this code to a file.
2. Execute it with ":luafile %". >
@ -859,6 +861,9 @@ vim.defer_fn({fn}, {timeout}) *vim.defer_fn*
Defers calling {fn} until {timeout} ms passes. Use to do a one-shot timer
that calls {fn}.
Note: The {fn} is |schedule_wrap|ped automatically, so API functions are
safe to call.
Parameters: ~
{fn} Callback to call once {timeout} expires
{timeout} Time in ms to wait before calling {fn}

View File

@ -467,6 +467,8 @@ end
--- Defers calling `fn` until `timeout` ms passes.
---
--- Use to do a one-shot timer that calls `fn`
--- Note: The {fn} is |schedule_wrap|ped automatically, so API functions are
--- safe to call.
--@param fn Callback to call once `timeout` expires
--@param timeout Number of milliseconds to wait before calling `fn`
--@return timer luv timer object