March 2020
Intermediate to advanced
328 pages
7h 58m
English
A Phoenix Channel is backed by a GenServer that lets it receive messages and store state. We can take advantage of this property of Channels to customize the behavior of our Channel on a per-connection level. This allows us to build flows that are not possible (or would be much more complex) with standard message broadcasting, which can’t easily send messages to a single client.
We can’t customize the behavior of Sockets as much due to their process structure. We’ll focus our attention strictly on Channel-level customization for these examples by walking through several different patterns that use Phoenix.Socket.assign/3 and message sending.
We sometimes need to send data to a client in a ...
Read now
Unlock full access