Compile-time support for reducer modules.
This module handles the compilation of @throttle and @debounce module attributes
into metadata functions that can be queried at runtime.
Module Attributes
@throttle
Throttle an action - execute immediately, then block for duration:
@throttle {"fetch-list", "3000ms"}
def handle_action(%{type: "fetch-list"}, state) do
# Only executes once per 3 seconds
end@debounce
Debounce an action - delay execution until duration passes since last call:
@debounce {"update-query", "500ms"}
def handle_action(%{type: "update-query", payload: query}, state) do
# Waits 500ms after last call before executing
endGenerated Functions
The compiler generates the following metadata functions:
__reducer_throttles__/0- Returns list of{action_pattern, duration}tuples__reducer_debounces__/0- Returns list of{action_pattern, duration}tuples__reducer_module__/0- Returnstrueto mark as a reducer module__reducer_action_prefix__/0- Returns the action prefix for routing (can be nil)
Summary
Functions
Called before module compilation completes.
Register a debounce attribute.
Register a throttle attribute.
Functions
Called before module compilation completes.
Generates metadata functions based on accumulated module attributes.
Register a debounce attribute.
Called automatically when @debounce is used in a reducer module.
Should not be called directly.
Register a throttle attribute.
Called automatically when @throttle is used in a reducer module.
Should not be called directly.