Closed checketts closed 2 years ago
Interesting, did not know you can add multiple events. Could you elaborate when this is useful?
We could support this on the annotation as well I think?
More events come into play if we are trying to do fine-grained UI updates. This is a contrived example, but imagine if a user was editing their preferences and the form let them change their display name and avatar. We might emit a user:name
and user:avatar
event on that response to trigger updates on the page.
Interestingly, oob updates and events are 2 different solutions that help with these secondary updates. I've been trying explore when each is appropriate.
Closed by #21
As I've begun using HTMX I've had some cases when I could choose to return multiple events, so I investigated the API. The following HX-Trigger headers could be set:
(along with the after-settle and after swap options)
To encapsulate these details I want to create an
HtmxResponse
object (combining @odrotbohm's HtmxPartials) with an api of:Alternatively we could use a builder style, but I'm not sure if it offers much benefit:
The shortest trigger option will be the most common (no details and the
RECEIVE
lifecycle)That way users don't need to generate the json. I don't think we need to support all these options in the annotation.