Enable Discovery debug logging for production troubleshooting
- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
This commit is contained in:
@@ -1,28 +1,59 @@
|
||||
// modules/example-module/index.js
|
||||
import { registerFrameTask, unregisterFrameTask } from '../../core/frameloop.js';
|
||||
import { Logger } from '../../core/logger.js';
|
||||
|
||||
let frameId = 'example-module';
|
||||
let resizeHandler = null;
|
||||
let state = null;
|
||||
|
||||
export function init(config = {}) {
|
||||
console.log('[example-module] init');
|
||||
/**
|
||||
* Initialize example module with state management
|
||||
* @param {Object} config - Module configuration
|
||||
* @param {Object} stateManager - Scoped state manager
|
||||
*/
|
||||
export function init(config = {}, stateManager = null) {
|
||||
Logger.info('[example-module] init');
|
||||
state = stateManager;
|
||||
|
||||
// z. B. Event-Listener hinzufügen
|
||||
// Register module state
|
||||
if (state) {
|
||||
state.register('windowSize', { width: window.innerWidth, height: window.innerHeight });
|
||||
state.register('scrollPosition', { x: 0, y: 0 });
|
||||
state.register('isVisible', true);
|
||||
|
||||
// Example: Subscribe to global app state (if exists)
|
||||
// state.subscribe('app.theme', (theme) => {
|
||||
// Logger.info(`[example-module] Theme changed to: ${theme}`);
|
||||
// });
|
||||
}
|
||||
|
||||
// Event-Listener mit State-Updates
|
||||
resizeHandler = () => {
|
||||
console.log('Fenstergröße geändert');
|
||||
const newSize = { width: window.innerWidth, height: window.innerHeight };
|
||||
Logger.info('Fenstergröße geändert:', newSize);
|
||||
|
||||
if (state) {
|
||||
state.set('windowSize', newSize);
|
||||
}
|
||||
};
|
||||
window.addEventListener('resize', resizeHandler);
|
||||
|
||||
// Scroll- oder Frame-Logik
|
||||
// Frame-Logik mit State-Updates
|
||||
registerFrameTask(frameId, () => {
|
||||
// wiederkehrende Aufgabe
|
||||
const scrollY = window.scrollY;
|
||||
// ggf. transformieren oder Werte speichern
|
||||
const scrollX = window.scrollX;
|
||||
|
||||
if (state) {
|
||||
const currentScroll = state.get('scrollPosition');
|
||||
if (currentScroll.x !== scrollX || currentScroll.y !== scrollY) {
|
||||
state.set('scrollPosition', { x: scrollX, y: scrollY });
|
||||
}
|
||||
}
|
||||
}, { autoStart: true });
|
||||
}
|
||||
|
||||
export function destroy() {
|
||||
console.log('[example-module] destroy');
|
||||
Logger.info('[example-module] destroy');
|
||||
|
||||
// EventListener entfernen
|
||||
if (resizeHandler) {
|
||||
@@ -33,5 +64,9 @@ export function destroy() {
|
||||
// FrameTask entfernen
|
||||
unregisterFrameTask(frameId);
|
||||
|
||||
// weitere Aufräumarbeiten, z.B. Observer disconnect
|
||||
}
|
||||
// State cleanup
|
||||
if (state && typeof state.cleanup === 'function') {
|
||||
state.cleanup();
|
||||
}
|
||||
state = null;
|
||||
}
|
||||
Reference in New Issue
Block a user