Elm-style reducer runtime backend.
An app using this backend defines init/1 (initial state), update/2
(msg, state -> new_state), and render/1. The loop's input events, named
callbacks, timers, and out-of-band messages are all delivered to update/2:
- raw input events arrive as their event tuple, e.g.
{:key, :q} - named callbacks arrive as
{name, data} - fired timers arrive as
{:timer, timer_id}
update/2 returns the new state, or {:stop, reason} to quit. Render is skipped when it
returns a state value-equal to the previous one.
An app that does not define update/2 falls back to the Callback backend.
Summary
Functions
Passes the raw event tuple to the app's update/2.
Passes a named callback to the app's update/2 as {name, data}.
Calls the app's init/1, falling back to Callback.mount/2 when it defines none.
Passes an out-of-band process message to the app's update/2 verbatim.
Delegates to Drafter.Runtime.Callback.ready/2.
Delegates to Drafter.Runtime.Callback.refresh_rate/1.
Passes a fired timer to the app's update/2 as {:timer, timer_id}.
Functions
@spec handle_input(module(), term(), term()) :: {:ok, term()} | {:noreply, term()} | {:stop, term()} | term()
Passes the raw event tuple to the app's update/2.
Returns {:noreply, state} when update/2 returns a state equal to the one passed
in, {:stop, reason} unchanged, and {:ok, new_state} otherwise. Apps without an
update/2 fall through to Drafter.Runtime.Callback.handle_input/3.
@spec handle_message(module(), atom(), term(), term()) :: {:ok, term()} | {:noreply, term()} | {:stop, term()} | term()
Passes a named callback to the app's update/2 as {name, data}.
Result shapes match handle_input/3. Apps without an update/2 fall through to
Drafter.Runtime.Callback.handle_message/4.
Calls the app's init/1, falling back to Callback.mount/2 when it defines none.
Passes an out-of-band process message to the app's update/2 verbatim.
Delegates to Drafter.Runtime.Callback.ready/2.
@spec refresh_rate(module()) :: Drafter.Runtime.refresh_rate()
Delegates to Drafter.Runtime.Callback.refresh_rate/1.
Delegates to Drafter.Runtime.Callback.scroll_active/2.
Delegates to Drafter.Runtime.Callback.scroll_idle/2.
Passes a fired timer to the app's update/2 as {:timer, timer_id}.
Returns whatever update/2 returns, without the equality check applied by
handle_input/3.