Created
April 17, 2024 00:32
-
-
Save dacook/b34f8148efbd2a771d0addb0addaad26 to your computer and use it in GitHub Desktop.
Hotwire Turbo events debug messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I couldn't easily install gem [hotwire-debug](https://github.com/beflagrant/hotwire-debug), | |
// so just copy/pasted the bare minimum source into my project. | |
// Then I updated the events list to include all events in the documentation: https://turbo.hotwired.dev/reference/events | |
// (hmmm, probably could have just added a general event listener and filtered by name ~= /turbo:/ | |
console.log('init hotwire-debug'); | |
var turboEvents = [ | |
"turbo:before-cache", | |
"turbo:before-render", | |
"turbo:before-visit", | |
"turbo:visit", | |
"turbo:click", | |
"turbo:load", | |
"turbo:render", | |
"turbo:submit-end", | |
"turbo:submit-start", | |
"turbo:morph", | |
"turbo:before-morph-element", | |
"turbo:morph-element", | |
"turbo:before-morph-attribute", | |
"turbo:before-frame-render", | |
"turbo:frame-render", | |
"turbo:frame-load", | |
"turbo:frame-missing", | |
"turbo:before-stream-render", | |
"turbo:before-fetch-request", | |
"turbo:before-fetch-response", | |
"turbo:before-prefetch", | |
"turbo:fetch-request-error", | |
] | |
turboEvents.forEach(function(turboEvent) { | |
document.addEventListener(turboEvent, function() { | |
// if (showChanges()) { | |
console.log("⚡️ " + turboEvent); | |
// handleChange(); | |
// } | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment