Files
michaelschiemer/resources/js/modules/event-bus/index.js
Michael Schiemer 36ef2a1e2c
Some checks failed
🚀 Build & Deploy Image / Determine Build Necessity (push) Failing after 10m14s
🚀 Build & Deploy Image / Build Runtime Base Image (push) Has been skipped
🚀 Build & Deploy Image / Build Docker Image (push) Has been skipped
🚀 Build & Deploy Image / Run Tests & Quality Checks (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Staging (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Production (push) Has been skipped
Security Vulnerability Scan / Check for Dependency Changes (push) Failing after 11m25s
Security Vulnerability Scan / Composer Security Audit (push) Has been cancelled
fix: Gitea Traefik routing and connection pool optimization
- Remove middleware reference from Gitea Traefik labels (caused routing issues)
- Optimize Gitea connection pool settings (MAX_IDLE_CONNS=30, authentication_timeout=180s)
- Add explicit service reference in Traefik labels
- Fix intermittent 504 timeouts by improving PostgreSQL connection handling

Fixes Gitea unreachability via git.michaelschiemer.de
2025-11-09 14:46:15 +01:00

94 lines
2.2 KiB
JavaScript

/**
* Event Bus Module
*
* Provides centralized event system for cross-module communication.
*
* Usage:
* - Add data-module="event-bus" to enable global event bus
* - Or import and use directly: import { EventBus } from './modules/event-bus/index.js'
*
* Features:
* - Pub/sub pattern
* - Namespaced events
* - Event filtering
* - Event history
* - Integration with LiveComponents
* - Integration with SSE
*/
import { Logger } from '../../core/logger.js';
import { EventBus, getGlobalEventBus } from './EventBus.js';
const EventBusModule = {
name: 'event-bus',
eventBus: null,
init(config = {}, state = null) {
Logger.info('[EventBusModule] Module initialized');
// Create global event bus
this.eventBus = getGlobalEventBus(config);
// Expose globally for easy access
if (typeof window !== 'undefined') {
window.EventBus = this.eventBus;
}
return this;
},
/**
* Get event bus instance
*/
getEventBus() {
return this.eventBus || getGlobalEventBus();
},
/**
* Emit an event
*/
emit(eventName, data = null, options = {}) {
const bus = this.getEventBus();
bus.emit(eventName, data, options);
},
/**
* Subscribe to an event
*/
on(eventName, callback, options = {}) {
const bus = this.getEventBus();
return bus.on(eventName, callback, options);
},
/**
* Unsubscribe from an event
*/
off(eventName, callback) {
const bus = this.getEventBus();
bus.off(eventName, callback);
},
destroy() {
if (this.eventBus) {
this.eventBus.destroy();
this.eventBus = null;
}
if (typeof window !== 'undefined' && window.EventBus) {
delete window.EventBus;
}
Logger.info('[EventBusModule] Module destroyed');
}
};
// Export for direct usage
export { EventBus, getGlobalEventBus };
// Export as default for module system
export default EventBusModule;
// Export init function for module system
export const init = EventBusModule.init.bind(EventBusModule);