Pax.Interface.Plugin behaviour (Pax v0.0.1-dev.20251023)
View SourcePax.Interface.Plugin is a behaviour for defining plugins that can be used with Pax.Interface.
use Pax.Interface.Plugin
When you use Pax.Interface.Plugin, your module will be declared as a behaviour for both Pax.Plugin as well
as Pax.Interface.Plugin.
Summary
Callbacks
after_params/2 occurs after all handle_params/4 callbacks in Pax.Interface, its plugins, and the user module.
It is called with the final params and socket, and must return a socket.
after_render/2 occurs after the main interface action, and before the user module gets a chance. It must always
return a socket. Any changes to the socket will not trigger a re-render.
handle_async/4 occurs during the normal LV handle_async/2 callback, after the main interface action, and before the user
module gets a chance. If it returns {:halt, socket} then the user module will never have its handle_async/2 called.
If the plugin implements handle_async/4 at all, then it must return {:cont, socket} for any events it has no interest
in handling, otherwise an UndefinedFunctionError will be raised.
handle_event/4 occurs during the normal LV handle_event/3 callback, after the main interface action, and before the user
module gets a chance. If it returns {:halt, socket} then the user module will never have its handle_event/3 called.
If the plugin implements handle_event/4 at all, then it must return {:cont, socket} for any events it has no interest
in handling, otherwise an UndefinedFunctionError will be raised.
handle_info/3 occurs during the normal LV handle_info/2 callback, after the main interface action, and before the user
module gets a chance. If it returns {:halt, socket} then the user module will never have its handle_info/2 called.
If the plugin implements handle_info/3 at all, then it must return {:cont, socket} for any events it has no interest
in handling, otherwise an UndefinedFunctionError will be raised.
handle_params/4 occurs during the handle_params/3 step of the LV initialization, before the main interface handles the
action.
Types
@type socket() :: Phoenix.LiveView.Socket.t()
A Phoenix.LiveView socket
@type unsigned_params() :: Phoenix.LiveView.unsigned_params()
Unsigned params from a Phoenix.LiveView handle_params/3
Callbacks
after_params/2 occurs after all handle_params/4 callbacks in Pax.Interface, its plugins, and the user module.
It is called with the final params and socket, and must return a socket.
after_render/2 occurs after the main interface action, and before the user module gets a chance. It must always
return a socket. Any changes to the socket will not trigger a re-render.
@callback handle_async( opts :: map(), name :: term(), async_fun_result :: {:ok, term()} | {:exit, term()}, socket :: socket() ) :: {:cont, socket()} | {:halt, socket()}
handle_async/4 occurs during the normal LV handle_async/2 callback, after the main interface action, and before the user
module gets a chance. If it returns {:halt, socket} then the user module will never have its handle_async/2 called.
If the plugin implements handle_async/4 at all, then it must return {:cont, socket} for any events it has no interest
in handling, otherwise an UndefinedFunctionError will be raised.
@callback handle_event( opts :: map(), event :: binary(), params :: unsigned_params(), socket :: socket() ) :: {:cont, socket()} | {:halt, socket()} | {:halt, reply :: map(), socket()}
handle_event/4 occurs during the normal LV handle_event/3 callback, after the main interface action, and before the user
module gets a chance. If it returns {:halt, socket} then the user module will never have its handle_event/3 called.
If the plugin implements handle_event/4 at all, then it must return {:cont, socket} for any events it has no interest
in handling, otherwise an UndefinedFunctionError will be raised.
@callback handle_info(opts :: map(), msg :: term(), socket :: socket()) :: {:cont, socket()} | {:halt, socket()}
handle_info/3 occurs during the normal LV handle_info/2 callback, after the main interface action, and before the user
module gets a chance. If it returns {:halt, socket} then the user module will never have its handle_info/2 called.
If the plugin implements handle_info/3 at all, then it must return {:cont, socket} for any events it has no interest
in handling, otherwise an UndefinedFunctionError will be raised.
@callback handle_params( opts :: map(), params :: unsigned_params(), uri :: String.t(), socket :: socket() ) :: {:cont, socket()} | {:halt, socket()}
handle_params/4 occurs during the handle_params/3 step of the LV initialization, before the main interface handles the
action.