Hello,
I’m experimenting with 1.7.0-rc.3, the stream feature, as it has been made default when generating live views.
One thing I’ve noticed is that stream_insert
in provided examples is issued inside handle_info
, with components triggering a message to the live view, which make me wonder if this is a limitation of some sort. In fact, attempt to stream_insert
inside a component wasn’t successful at all.
So, I just followed the same principle (component sends a message, the view handles it).
In my case I’m sending a SQL via Ecto to update several elements to leave just one, within a group, with a checkbox. I’m receiving several items back as updated, so I can notify the view about these individually.
First thing first, I can’t send a bunch at once, so instead, I’m using Enum.reduce
:
def handle_info({ModuleName, {:updated, cells}}, socket) do
socket = Enum.reduce(cells, socket, fn c, acc -> stream_insert(acc, :cells, c) end)
{:noreply, socket}
end
The glitches begin after the first click, if it goes beyond the checkbox group. The socket at the browser side reports:
no component found matching phx-target of 1 undefined utils.js:7:61
logError utils.js:7
withinTargets view.js:217
exec_push js.js:43
exec js.js:17
exec js.js:16
exec js.js:12
bindClick live_socket.js:648
withinOwners live_socket.js:434
owner live_socket.js:430
withinOwners live_socket.js:434
bindClick live_socket.js:647
debounce live_socket.js:881
debounce dom.js:188
debounce live_socket.js:880
withinOwners live_socket.js:434
owner live_socket.js:430
withinOwners live_socket.js:434
debounce live_socket.js:878
bindClick live_socket.js:646
(Async: EventListener.handleEvent)
bindClick live_socket.js:626
bindClicks live_socket.js:620
bindTopLevelEvents live_socket.js:520
doConnect live_socket.js:209
connect live_socket.js:219
<anonymous> app.js:34
<anonymous> app.js:5464
and refuses to add any changes.
Strangely, the modification is still possible among the items within original group that received the first stream_insert.
So, I’m puzzled and asking for any help possible. Thank you!