File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change 11# Assigns and HEEx templates
22
33All of the data in a LiveView is stored in the socket as assigns.
4+ The socket state is a server side struct in ` Phoenix.LiveView.Socket `
5+ and ` Phoenix.Socket ` which maintains state through a GenServer,
6+ there is one process per socket connection, the socket is never
7+ shared with the client.
8+
49The ` Phoenix.Component.assign/2 ` and ` Phoenix.Component.assign/3 `
510functions help store those values. Those values can be accessed
611in the LiveView as ` socket.assigns.name ` but they are accessed
Original file line number Diff line number Diff line change @@ -37,6 +37,12 @@ defmodule Phoenix.LiveView do
3737 Any time a stateful view changes or updates its socket assigns, it is
3838 automatically re-rendered and the updates are pushed to the client.
3939
40+ Socket assigns are values kept on the server side by
41+ `Phoenix.Socket`, this is different from the common pattern of sending
42+ the connection state to the client in the form of a token or cookie,
43+ typically used in HTTP requests. Under the hood there is a GenServer that
44+ creates a process for each socket connection through `Phoenix.LiveView.Socket`.
45+
4046 You begin by rendering a LiveView typically from your router.
4147 When LiveView is first rendered, the `c:mount/3` callback is invoked
4248 with the current params, the current session and the LiveView socket.
You can’t perform that action at this time.
0 commit comments