Re-render JS on a Live view update - how to?

if I have this code in a template:

<%= if is_nil(@value) do %>
        # custom functions
<% else %>
    # custom functions
<% end %>

I can see in the inspect elements the following behaviour: on mount if value is nil it logs into the JS console the right string. If value of @value is changed via a socket.update/3, the <script> elements are changed correctly, it shows <script> console.log("hello2") </script>, but that log is not being rendered, there is no new “messages” in the JS console. Only the html side, if I may say so, is re-rendered. What could be the right way to achieve what I want? Sorry for my bad explanation

This is not going to work with inline scripts. Consider another method like hooks or event handlers + dispatching event to trigger JS from a LV.