Packages

PhoenixLiveState enables LiveView processes to share reactive state across a cluster of nodes. Attach LiveViews to a state server and get automatic assign synchronization.

Current section

Files

Jump to
phoenix_live_state lib phoenix_live_state.ex
Raw

lib/phoenix_live_state.ex

defmodule PhoenixLiveState do
@moduledoc """
Use this module to integrate PhoenixLiveState with your liveviews.
"""
@moduledoc since: "0.1.0"
def state(opts) do
quote do
use PhoenixLiveState.StateSpec, unquote(opts)
end
end
def client(opts) do
live_state_configured? = opts[:live_state] != nil
if live_state_configured? do
quote do
use PhoenixLiveState.LiveView.Hooks, unquote(opts)
import PhoenixLiveState.LiveView.Integration
end
else
quote do
end
end
end
defmacro __using__(which) when is_atom(which) do
apply(__MODULE__, which, [[]])
end
defmacro __using__([{which, opts}]) do
apply(__MODULE__, which, [opts])
end
end