Debouncex

A process debouncer for Elixir

What is Debounce?

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.

# Example

  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> :world

Installation

If available in Hex, the package can be installed by adding elixir_debounce to your list of dependencies in mix.exs:

def deps do
  [
    {:debouncex, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/debouncex.