Development on Phoenix LiveView is of course in full swing. However, here are a couple of features I currently miss and proposals to add them to Phoenix LiveView.
Currently, LiveView supports
In multiple projects I have encountered cases with a large need for other types of interaction. Specifically, custom form elements frequently require things to happen on mousedown, when dragging, or when doubleclicking.
I propose that the following events are added to LiveView (whose behaviour is similar to
phx-click in that the same extra information is sent, as well as the
phx-value-*s that are set on that particular element):
Supporting other click-like events
I believe above list covers the most common interactions. Of course, there exist many more mouse-related (as well as more general touch-related) events.
On top of above list of events, I therefore propose that it should be made easier to hook into the existing code that sends a
phx-click-like event to the server.
To be more precise, the following is very difficult (already right now) to accurately reproduce in a custom JS hook:
- The new event should include all
phx-value-*s using the same naming conventions/conversions as a normal (built-in) event.
- The new event should include the same meta information with the request.
- The new event should adhere to supplied
- The new event should trigger on the correctly specified
- This list will grow and change with future features being added to LiveView.
Some standardized way to add a new type of click-like event to a Phoenix LiveView instance would be a solution, such as adding a configuration field that accepts a list of event-names or alternatively an object of
event name keys with
callback function values, where the callback function is able to do things before an event is dispatched and can
yield to the event dispatching logic at some point (either by using ES6 features or by e.g. just passing in the function that can do the work as argument to the callback function so it can call it whenever it likes).