Skip to content

Commit

Permalink
feat: expose tasks.current_task
Browse files Browse the repository at this point in the history
See #4
  • Loading branch information
rcarriga committed Jan 21, 2024
1 parent b789a35 commit f12c3b1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions doc/nio.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ Parameters~
Return~
`(any[])` Results of all functions

*nio.current_task()*
`current_task`()

Get the current running task, if any.
Return~
`(nio.tasks.Task|nil)`

*nio.first()*
`first`({functions})

Expand Down
6 changes: 6 additions & 0 deletions lua/nio/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ function nio.gather(functions)
return sorted
end

--- Get the current running task, if any.
---@return nio.tasks.Task|nil
function nio.current_task()
return tasks.current_task()
end

--- Run a collection of async functions concurrently and return the result of
--- the first to finish.
---@async
Expand Down

0 comments on commit f12c3b1

Please sign in to comment.