Alternera.Resource.UI.Surface behaviour (alternera_resource_ui v0.9.0)

Copy Markdown View Source

The optional callbacks of a surface (use Alternera.Resource.UI, :surface), for one offered as a Workbench item: the Workbench calls them as it calls its own item types.

  • load/2 runs when the tab opens and when a reload restores it, with the arg the tab was opened on; what it returns is the component's state assign until the tab closes. Without it state is nil.
  • title/1 names the tab from that state; without it the tab takes the declaration's label.
  • request_close/1: the tab asks before it closes; {:ask, question} keeps it open with the question shown (unsaved work).

Summary

Callbacks

load(arg, t)

(optional)
@callback load(arg :: String.t() | nil, Alternera.Resource.UI.Context.t()) ::
  {:ok, term()} | {:error, String.t()}

request_close(state)

(optional)
@callback request_close(state :: term()) :: :close | {:ask, String.t()}

title(state)

(optional)
@callback title(state :: term()) :: String.t()