Skip to content

Commit

Permalink
Debug turbo events in development
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Sep 11, 2024
1 parent 8261bc8 commit e7a97f9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
17 changes: 17 additions & 0 deletions frontend/src/turbo/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export const TURBO_EVENTS:string[] = [
'turbo:click',
'turbo:before-visit',
'turbo:visit',
'turbo:submit-start',
'turbo:before-fetch-request',
'turbo:before-fetch-response',
'turbo:submit-end',
'turbo:before-cache',
'turbo:before-render',
'turbo:before-stream-render',
'turbo:render',
'turbo:load',
'turbo:frame-render',
'turbo:frame-load',
'turbo:fetch-request-error',
];
11 changes: 11 additions & 0 deletions frontend/src/turbo/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,23 @@ import { registerDialogStreamAction } from './dialog-stream-action';
import { addTurboEventListeners } from './turbo-event-listeners';
import { registerFlashStreamAction } from './flash-stream-action';
import { applyTurboNavigationPatch } from './turbo-navigation-patch';
import { debugLog, whenDebugging } from 'core-app/shared/helpers/debug_output';
import { TURBO_EVENTS } from './constants';

// Disable default turbo-drive for now as we don't need it for now AND it breaks angular routing
Turbo.session.drive = false;
// Start turbo
Turbo.start();

// Register logging of events
whenDebugging(() => {
TURBO_EVENTS.forEach((name:string) => {
document.addEventListener(name, (event) => {
debugLog(`[TURBO EVENT ${name}] %O`, event);
});
});
});

// Register our own actions
addTurboEventListeners();
registerDialogStreamAction();
Expand Down

0 comments on commit e7a97f9

Please sign in to comment.