mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-02-26 12:03:02 +01:00
Move Stimulus loading into an initializer
This commit is contained in:
parent
1b289f02cb
commit
e35bf6da17
3 changed files with 13 additions and 7 deletions
|
@ -1,6 +1,3 @@
|
|||
import { Application } from '@hotwired/stimulus';
|
||||
import { definitionsFromContext } from '@hotwired/stimulus-webpack-helpers';
|
||||
|
||||
import start from 'retrospring/common';
|
||||
import initAnswerbox from 'retrospring/features/answerbox';
|
||||
import initCapabilities from 'retrospring/features/capabilities';
|
||||
|
@ -30,7 +27,3 @@ document.addEventListener('DOMContentLoaded', initMemes);
|
|||
document.addEventListener('turbo:load', initFront);
|
||||
document.addEventListener('DOMContentLoaded', initWebpush);
|
||||
document.addEventListener('turbo:load', initWebpushSettingsButtons);
|
||||
|
||||
window['Stimulus'] = Application.start();
|
||||
const context = require.context('../retrospring/controllers', true, /\.ts$/);
|
||||
window['Stimulus'].load(definitionsFromContext(context));
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import '@hotwired/turbo-rails';
|
||||
import bootstrap from './initializers/bootstrap';
|
||||
import stimulus from './initializers/stimulus';
|
||||
|
||||
export default function start(): void {
|
||||
try {
|
||||
|
|
12
app/assets/javascript/retrospring/initializers/stimulus.ts
Normal file
12
app/assets/javascript/retrospring/initializers/stimulus.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { Application } from '@hotwired/stimulus';
|
||||
|
||||
import AnnouncementController from "retrospring/controllers/announcement_controller";
|
||||
import AutofocusController from "retrospring/controllers/autofocus_controller";
|
||||
import CharacterCountController from "retrospring/controllers/character_count_controller";
|
||||
|
||||
export default function (): void {
|
||||
window.Stimulus = Application.start();
|
||||
window.Stimulus.register('announcement', AnnouncementController);
|
||||
window.Stimulus.register('autofocus', AutofocusController);
|
||||
window.Stimulus.register('character_count', CharacterCountController);
|
||||
}
|
Loading…
Reference in a new issue