LiveView's new JS.exec/3 function
Notes
Phoenix 1.7.2 shipped a new JS.exec/3
function.
It allows us to execute JS defined in a different dom element.
Why would we want that?
If we’re repeating the same code in multiple places (e.g. hide modal), even if we’re using a helper function to reduce code duplication, we might still be sending that several times in the payload!
JS.exec/3
allows us to reduce that payload by only including the JS command in
a single place – a “canonical” place (as I call it).