Flop.Phoenix.Live.PaginationComponent (Flop Phoenix v0.5.0) View Source
LiveView component for pagination.
This component takes the same configuration as Flop.Phoenix.pagination/4
. It
uses Phoenix.LiveView.Helpers.live_patch/2
to display the pagination links,
so you will have to handle the pagination parameters in the handle_params/3
callback function of your LiveView.
Example
defmodule MyAppWeb.PetLive.Index do
use MyAppWeb, :live_view
alias MyApp.Pets
@impl Phoenix.LiveView
def mount(_params, _session, socket) do
{:ok, socket)}
end
@impl Phoenix.LiveView
def handle_params(params, _, socket) do
with {:ok, {pets, meta}} = Pets.list_pets(params) do
{noreply, assign(socket, %{pets: pets, meta: meta})}
{:error, reason} ->
# handle error
{noreply, socket}
end
end
end
Link to this section Summary
Functions
Callback implementation for Phoenix.LiveComponent.render/1
.
Link to this section Functions
Callback implementation for Phoenix.LiveComponent.render/1
.