Pax.Interface.Plugin behaviour (Pax v0.0.1-dev)
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_render/2 occurs after the main interface action, and before the user module gets a chance. It must always return a socket.
on_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 on_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.
on_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 on_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.
on_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 on_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.
on_loaded occurs during the handle_params/3 step of the LV initialization, after the main interface handles the action, right before the user module's handle_params/3 is finally called..
on_preload 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_render/2 occurs after the main interface action, and before the user module gets a chance. It must always return a socket.
@callback on_async( opts :: map(), name :: term(), async_fun_result :: {:ok, term()} | {:exit, term()}, socket :: socket() ) :: {:cont, socket()} | {:halt, socket()}
on_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 on_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 on_event( opts :: map(), event :: binary(), params :: unsigned_params(), socket :: socket() ) :: {:cont, socket()} | {:halt, socket()} | {:halt, reply :: map(), socket()}
on_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 on_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 on_info(opts :: map(), msg :: term(), socket :: socket()) :: {:cont, socket()} | {:halt, socket()}
on_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 on_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 on_loaded( opts :: map(), params :: unsigned_params(), uri :: String.t(), socket :: socket() ) :: {:cont, socket()} | {:halt, socket()}
on_loaded occurs during the handle_params/3 step of the LV initialization, after the main interface handles the action, right before the user module's handle_params/3 is finally called..
@callback on_preload( opts :: map(), params :: unsigned_params(), uri :: String.t(), socket :: socket() ) :: {:cont, socket()} | {:halt, socket()}
on_preload occurs during the handle_params/3 step of the LV initialization, before the main interface handles the action.