WaitForIt
Various ways to wait for things to happen.
Since most Elixir systems are highly concurrent, there must be a way to coordinate and synchronize
the processes in the system. While the language provides features (such as
Process.sleep/1 and receive/after) that can be used to implement such synchronization, they are
inconvenient to use for this purpose. WaitForIt builds on top of these language features to
provide convenient and easy-to-use facilities for synchronizing concurrent activities. While
this is likely most useful for test code in which tests must wait for concurrent or asynchronous
activities to complete, it is also useful in any scenario where concurrent processes must
coordinate their activity. Examples include asynchronous event handling, producer-consumer
processes, and time-based activity.
There are three distinct forms of waiting provided:
-
The
waitmacro waits until a given expression evaluates to a truthy value. -
The
case_waitmacro waits until a given expression evaluates to a value that matches any one of the given case clauses (looks like an Elixircaseexpression). -
The
cond_waitmacro waits until any one of the given expressions evaluates to a truthy value (looks like an Elixircondexpression).
See the API reference for full documentation.
Installation
wait_for_it can be installed from Hex by adding wait_for_it to your list
of dependencies in mix.exs:
def deps do
[
{:wait_for_it, "~> 1.1"}
]
endDocumentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/wait_for_it.
Sponsored by Ropig http://ropig.com