A process debouncer for Elixir
Debounce will call function with delay timeout, but if function is called multiple time with delay period, the time is reset and delay is counted again. Like debounce in Javascript but for Elixir.
iex> defmodule Hello do
def hello do
:world
end
end
iex> {:ok, pid} = Debouncex.start_link({
&Hello.hello/0,
[],
1000
})
iex> Debouncex.call(pid) # Scheduler call after 1s
iex> :timer.sleep(100)
iex> Debouncex.call(pid) # Scheduler call after 1s
iex> :worldIf available in Hex, the package can be installed
by adding debouncex to your list of dependencies in mix.exs:
def deps do
[
{:debouncex, "~> 0.1.0"}
]
end