mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 14:38:32 +00:00
doc: mention that defer_fn applies schedule_wrap (#12601)
This commit is contained in:
@@ -415,6 +415,8 @@ To avoid the error use |vim.schedule_wrap()| to defer the callback: >
|
|||||||
vim.api.nvim_command('echomsg "test"')
|
vim.api.nvim_command('echomsg "test"')
|
||||||
end))
|
end))
|
||||||
|
|
||||||
|
(For one-shot timers, see |vim.defer_fn()|, which automatically adds the wrapping.)
|
||||||
|
|
||||||
Example: repeating timer
|
Example: repeating timer
|
||||||
1. Save this code to a file.
|
1. Save this code to a file.
|
||||||
2. Execute it with ":luafile %". >
|
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
|
Defers calling {fn} until {timeout} ms passes. Use to do a one-shot timer
|
||||||
that calls {fn}.
|
that calls {fn}.
|
||||||
|
|
||||||
|
Note: The {fn} is |schedule_wrap|ped automatically, so API functions are
|
||||||
|
safe to call.
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
{fn} Callback to call once {timeout} expires
|
{fn} Callback to call once {timeout} expires
|
||||||
{timeout} Time in ms to wait before calling {fn}
|
{timeout} Time in ms to wait before calling {fn}
|
||||||
|
@@ -467,6 +467,8 @@ end
|
|||||||
--- Defers calling `fn` until `timeout` ms passes.
|
--- Defers calling `fn` until `timeout` ms passes.
|
||||||
---
|
---
|
||||||
--- Use to do a one-shot timer that calls `fn`
|
--- 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 fn Callback to call once `timeout` expires
|
||||||
--@param timeout Number of milliseconds to wait before calling `fn`
|
--@param timeout Number of milliseconds to wait before calling `fn`
|
||||||
--@return timer luv timer object
|
--@return timer luv timer object
|
||||||
|
Reference in New Issue
Block a user