Like @aenglisc said, there’s a confusing mix of stream
and assign
for list of products. It should usually be one or the other for any particular data structure.
The simplest approach to get the book code working would likely be switching the use of stream
in the mount
callback to assign
i.e. {:ok, assign(socket, :products, Catalog.list_products()}
. All of the book code’s view templates are referencing the products in the top level of the socket assigns and not the products nested under the streams key in the socket assigns.
If you really want to use the new streaming functionality, you’ll have to update the book code to re-stream_insert
all the individual products within the :products
stream since there’s no API to replace an entire stream at the collection level – at least for now. For more details, see: How to replace LiveView stream with new items? (reset or re-assigning) - #2 by codeanpeace