-
Notifications
You must be signed in to change notification settings - Fork 4
fix(htmx): added fetch
wrapper to support Hx-Trigger
feature like htmx request
#56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's Guide by SourceryThis pull request introduces a wrapper around the native Sequence diagram for fetch wrapper with Hx-Trigger supportsequenceDiagram
participant Browser
participant fetchWrapper as $x.fetch
participant Server
participant CustomEventDispatcher
Browser->>fetchWrapper: fetch(url, options)
fetchWrapper->>Server: HTTP Request
Server-->>fetchWrapper: HTTP Response (with Hx-Trigger header)
alt Hx-Trigger header exists
fetchWrapper->>CustomEventDispatcher: Parse Hx-Trigger
loop For each trigger in Hx-Trigger
CustomEventDispatcher->>Browser: dispatchEvent(CustomEvent(trigger))
end
end
fetchWrapper-->>Browser: Response
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Here's the code health analysis summary for commits Analysis Summary
|
Codecov ReportAll modified and coverable lines are covered by tests β
Additional details and impacted files@@ Coverage Diff @@
## main #56 +/- ##
=======================================
Coverage 94.27% 94.27%
=======================================
Files 56 56
Lines 2305 2305
=======================================
Hits 2173 2173
Misses 98 98
Partials 34 34
Flags with carried forward coverage won't be shown. Click here to find out more. β View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @cnlangzi - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider using a more descriptive name than
$x
for the global object. - The
fetch
wrapper could be simplified by usingresponse.headers.forEach
instead of manually iterating over the keys.
Here's what I looked at during the review
- π‘ General issues: 1 issue found
- π’ Security: all looks good
- π’ Testing: all looks good
- π’ Complexity: all looks good
- π’ Documentation: all looks good
Help me be more useful! Please click π or π on each comment and I'll use the feedback to improve your reviews.
Changed
Fixed
Added
Tests
Tasks to complete before merging PR:
make unit-test
to check for any regressions πmake lint
to check for any issuesSummary by Sourcery
This pull request introduces a
fetch
wrapper to support theHx-Trigger
feature, enabling server-sent events to trigger client-side actions like HTMX requests. It also renames the global object fromxun
to$x
.New Features:
fetch
function to support theHx-Trigger
header, allowing server-sent events to trigger client-side actions similar to HTMX requests.Enhancements:
xun
to$x
.