KinoPhoenixLiveView.RootLive (kino_phoenix_live_view v0.1.2)
The default LiveView for KinoPhoenixLiveView, used both to verify LiveView interactions and to guide developers on how to customize the integration.
This LiveView displays a simple toggle button along with instructions on how to:
- Replace the default LiveView with a custom one.
- Override the layout by providing a custom module.
- Override the router or endpoint.
Developers can use these instructions as a starting point to build their own LiveView experience.
Summary
Functions
Handles the "toggle" event by flipping the boolean state.
Mounts the LiveView and initializes the socket with a default boolean state.
Renders the default LiveView template.
Functions
Handles the "toggle" event by flipping the boolean state.
When the button is clicked, the LiveView toggles the value of :value
.
Parameters
"toggle"
: The event name._params
: The event parameters (unused).socket
: The LiveView socket.
Returns
{:noreply, socket}
with the updated:value
assign.
Mounts the LiveView and initializes the socket with a default boolean state.
Parameters
_params
: Request parameters (unused)._session
: Session data (unused).socket
: The LiveView socket.
Returns
{:ok, socket}
with the assign:value
set totrue
.
Renders the default LiveView template.
The template includes:
- A welcome header.
- Instructions on how to replace or customize the default LiveView, layout, router, or endpoint.
- A display of the current boolean state.
- A button to toggle the state for testing interactivity.
Parameters
assigns
: A map containing the LiveView assigns, including:value
.
Example
<h1>Welcome to KinoPhoenixLiveView!</h1>
<p>Current value: true</p>
<button phx-click="toggle">Toggle Value</button>