title: How to send events directly from Phoenix Live View to a component
body: <p>I have a question about the Phoenix LiveView Component (v0.15.4).</p>
  <p>In the documentation, there is an example code:</p>
  <pre><code>def handle_info({:updated_card, card}, socket) do
    send_update CardComponent, id: card.id, board_id: socket.assigns.id
    {:noreply, socket}
  end
  </code></pre>
  <p>LiveView components do not have a <code>handle_info/2</code> callback, so <code>send_update/3</code> is called to redirect events from the parent LiveView to a specific component.</p>
  <p>However, I want to send events directly from the parent LiveView to the specific component, because I want to do something like this</p>
  <pre><code># parent LiveView
  def handle_info({:new_card, card_id}, socket) do
    send_event CardStackComponent, id: :card_stack, event: &quot;add_card&quot;, params: %{&quot;card_id&quot; =&gt; card_id}
    {:noreply, socket}
  end
  
  # component
  def handle_event(&quot;add_card&quot;, %{&quot;card_id&quot; =&gt; card_id} = _params, socket) do
    card = get_card(card_id)
  
    socket =
      update(socket, :cards, fn cards -&gt;)
        [card | cards]     
      end)
      
    {:noreply, socket}
  end
  </code></pre>
  <p>Of course, there is no such function as <code>Phoenix.LiveView.send_event/2</code>. The above is a fictional code to illustrate my intention.</p>
  <p>I know how to send events from a client (browser) to a specific component, either by adding the <code>phx-target=&quot;&lt;%= @myself %&gt;&quot;</code> attribute to an HTML element, or by using the <code>pushEventTo</code> method in a JavaScript program.</p>
  <p>However, as far as I know, there is no way to send an event directly from a parent LiveView to a specific component.</p>
  <p>Is there any workaround or better way?</p>