mauricius / laravel-htmx

Laravel helper library for Htmx
MIT License
301 stars 14 forks source link

Support object events for `addTrigger` in addition to strings #13

Closed sbrow closed 9 months ago

sbrow commented 10 months ago

The htmx docs for HX-Trigger state that events can be strings, but can also be any JSON serializable value.

Would you be open to a PR in this regard?

Example


Input:

with(new HtmxResponse())->addTrigger('showMessage', ['level' => 'info', 'message', 'Here Is A Message'])

Output:

HX-Trigger: {"showMessage":{"level" : "info", "message" : "Here Is A Message"}}

What would happen if you call addTrigger with the same event name twice is up for debate.