Skip to content

Commit

Permalink
refactor(trigger): improve detail param names
Browse files Browse the repository at this point in the history
`detail string` -> `detailValue string`
`object any` -> `detailObject any`
  • Loading branch information
angelofallars committed Nov 24, 2023
1 parent bf8d4cd commit 1c34a92
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ values.
Define event triggers:

- `htmx.Trigger(eventName string)` - A trigger with no details.
- `htmx.TriggerDetail(eventName string, detail string)` - A trigger with one detail value.
- `htmx.TriggerObject(eventName string, object any)` - A trigger with a JSON-serializable detail
- `htmx.TriggerDetail(eventName string, detailValue string)` - A trigger with one detail value.
- `htmx.TriggerObject(eventName string, detailObject any)` - A trigger with a JSON-serializable detail
object. Recommended to pass in either `map[string]string` or structs with JSON field tags.

Set trigger headers using the triggers above:
Expand Down
8 changes: 4 additions & 4 deletions respheaders.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,10 @@ func Trigger(eventName string) triggerPlain {
// HX-Trigger: {"showMessage":"Here Is A Message"}
//
// For more info, see https://htmx.org/headers/hx-trigger/
func TriggerDetail(eventName string, detail string) triggerDetail {
func TriggerDetail(eventName string, detailValue string) triggerDetail {
return triggerDetail{
eventName: eventName,
value: detail,
value: detailValue,
}
}

Expand All @@ -335,10 +335,10 @@ func TriggerDetail(eventName string, detail string) triggerDetail {
// HX-Trigger: {"showMessage":{"level" : "info", "message" : "Here Is A Message"}}
//
// For more info, see https://htmx.org/headers/hx-trigger/
func TriggerObject(eventName string, object any) triggerObject {
func TriggerObject(eventName string, detailObject any) triggerObject {
return triggerObject{
eventName: eventName,
object: object,
object: detailObject,
}
}

Expand Down

0 comments on commit 1c34a92

Please sign in to comment.