Drafter.Runtime.Callback (drafter v0.3.1)

Copy Markdown View Source

Default LiveView-style runtime backend.

Adapts the loop to an app's mount/1, handle_event/2 (raw input events), handle_event/3 (named callbacks), and the optional lifecycle hooks. Optional hooks that an app does not define fall through to returning the state unchanged.

Summary

Functions

Calls the app's handle_event/2 with the raw event tuple.

Calls the app's handle_event/3 with the callback name and its payload.

Calls the app's mount/1 with the mount props.

Calls the app's on_message/2 if it defines one, otherwise returns state unchanged.

Calls the app's on_ready/1 if it defines one, otherwise returns state unchanged.

The app's refresh_rate/0 if it defines one, otherwise nil.

Calls the app's on_scroll_active/1 if it defines one, otherwise returns state unchanged.

Calls the app's on_scroll_idle/1 if it defines one, otherwise returns state unchanged.

Calls the app's on_timer/2 if it defines one, otherwise returns state unchanged.

Functions

handle_input(app, event, state)

@spec handle_input(module(), term(), term()) :: term()

Calls the app's handle_event/2 with the raw event tuple.

handle_message(app, name, data, state)

@spec handle_message(module(), atom(), term(), term()) :: term()

Calls the app's handle_event/3 with the callback name and its payload.

mount(app, props)

@spec mount(module(), map()) :: term()

Calls the app's mount/1 with the mount props.

on_message(app, msg, state)

@spec on_message(module(), term(), term()) :: term()

Calls the app's on_message/2 if it defines one, otherwise returns state unchanged.

ready(app, state)

@spec ready(module(), term()) :: term()

Calls the app's on_ready/1 if it defines one, otherwise returns state unchanged.

refresh_rate(app)

@spec refresh_rate(module()) :: Drafter.Runtime.refresh_rate()

The app's refresh_rate/0 if it defines one, otherwise nil.

scroll_active(app, state)

@spec scroll_active(module(), term()) :: term()

Calls the app's on_scroll_active/1 if it defines one, otherwise returns state unchanged.

scroll_idle(app, state)

@spec scroll_idle(module(), term()) :: term()

Calls the app's on_scroll_idle/1 if it defines one, otherwise returns state unchanged.

timer(app, timer_id, state)

@spec timer(module(), term(), term()) :: term()

Calls the app's on_timer/2 if it defines one, otherwise returns state unchanged.