Skip to content

http: send a constant zero as the TriggerEvent detail - #121

Merged
rameel merged 2 commits into
mainfrom
http/trigger-event-generic-detail
Nov 2, 2026
Merged

rameel merged 2 commits into
mainfrom
http/trigger-event-generic-detail

Conversation

@rameel

@rameel rameel commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

TriggerEvent("count", 0) selected the overload with only a timing, because a constant zero converts to any enum. The detail was lost, and the browser received {"count":{}}. The same applied to 0L, 0.0, and 0m. Variables were not affected.

This PR adds TriggerEvent<T>(string, T, HtmxTriggerTiming) next to the object overload.

The object overload stays, so TriggerEvent("x", null) still compiles and compiled code keeps working.

TriggerEvent("count", 0) selected the overload with only a timing,
because a constant zero converts to any enum. The detail was lost, and
the browser received {"count":{}}. The same applied to 0L, 0.0, and 0m.

Add a generic overload next to the object one: an exact match on T beats
the enum conversion. It passes the detail on as object, so the JSON
still follows the runtime type; serializing by T would drop the
properties of a derived type behind a base-typed variable.
@rameel
rameel merged commit b7fb84b into main Nov 2, 2026
1 of 2 checks passed
@rameel
rameel deleted the http/trigger-event-generic-detail branch November 2, 2026 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant