Built-in state-transition rules for tables.
Configured under the hooks.builtins DSL section. Each rule is opt-in
(default false) except :clear_selection_after_bulk which defaults to
true because it matches existing behavior.
Rules:
:switch_to_active_on_empty_archive— after a successful unarchive / permanent_destroy in:archivedmode, switch to:activemode once the archive list is observed empty on the next load.:switch_to_archive_on_empty_active— symmetric (rare; opt-in).:clear_selection_after_bulk— read by the bulk action handler.:reset_page_on_empty_current_page— if the current page becomes empty andpage > 1, reload page 1.:redirect_on_empty— whentotal_count == 0after a load, navigate to a path (string) orfn state -> path end.
Flow
Row actions don't normally reload, so after_row_action/3 triggers a reload
when any rule is enabled and stores :armed_action on the socket assigns.
Bulk actions already reload; after_bulk_action/3 just arms the flag.
after_load/2 (called from DataLoader.handle_async) reads the armed flag,
applies the relevant rule, and clears the flag.
See MishkaGervaz.Table.Web.State,
MishkaGervaz.Table.Web.DataLoader,
MishkaGervaz.Table.Web.Refresh,
MishkaGervaz.Table.Dsl.Hooks (rules live under the hooks DSL section).
Summary
Functions
Arm flags after a bulk action — the bulk handler already triggers a reload.
Apply built-in rules right after DataLoader.handle_async finishes loading.
Apply rules after a row action completed.
Types
@type socket() :: Phoenix.LiveView.Socket.t()
Functions
@spec after_bulk_action(socket(), MishkaGervaz.Table.Web.State.t(), map() | nil) :: socket()
Arm flags after a bulk action — the bulk handler already triggers a reload.
@spec after_load(socket(), MishkaGervaz.Table.Web.State.t()) :: socket()
Apply built-in rules right after DataLoader.handle_async finishes loading.
@spec after_row_action(socket(), MishkaGervaz.Table.Web.State.t(), atom()) :: socket()
Apply rules after a row action completed.
If any rule is enabled, arm the socket and trigger a fresh load so
after_load/2 can react to the new total_count.
@spec config(MishkaGervaz.Table.Web.State.t()) :: map()
@spec enabled?(MishkaGervaz.Table.Web.State.t(), atom()) :: boolean()
@spec value(MishkaGervaz.Table.Web.State.t(), atom()) :: term()