Sending events from JS to LiveView component

I know I can have heex attributes like phx-click="eventid" in the markup and then

def handle_event("eventid", _, socket), do: [...]

But how does one send that event without actually interacting? There are some examples in the guides like:

yet they seem to cover different cases:

  • handle custom client-side JavaScript when an element is added, updated, or removed by the server
  • Triggering phx- form events with JavaScript

but what I need is best described as “triggering arbitrary event that can be handled with handle_event/3 with JavaScript”. I found something similar here:

yet it’s been some time and many Phoenix changes since that fine piece was written.

How would you approach this task today?