littlechat
littlechat copied to clipboard
Migrate HTML Data-Passing Hooks Pattern to LiveView v0.14's New `push_event` Function
LiveView v0.14.0 added a new function, push_event/3 (docs), which allows us to push data from the server to the client's JS.
This solves an issue requiring a workaround in the original implementation of this app which required first creating a new HTML element in the LiveView with a dataset and JS hooks in order to pass data from the server to a client's JS. Since push_event/3 solves the problem (and should simplify and clean up the LiveView), let's implement it.
+1
getting a ton of no DOM ID for hook "HandleIceCandidateOffer". Hooks require a unique ID on each element.
which leads to js breaking: eg TypeError: undefined is not an object (evaluating 'e.__trigger__')
(called here https://github.com/phoenixframework/phoenix_live_view/blob/931ff3cafee547635689d2557d752a500403fe46/assets/js/phoenix_live_view.js#L1622)
and the payloads doesn't seem to have unique ids making a quick fix difficult..
Thanks for the heads up. We can just throw the index of the given assign’s element in as part of an ID for each generated element until we get a chance to switch over to using push_event.