chore: complete update

This commit is contained in:
2025-07-17 16:24:20 +02:00
parent 899227b0a4
commit 64a7051137
1300 changed files with 85570 additions and 2756 deletions

View File

@@ -0,0 +1,46 @@
// src/core/events.js
// --- 1. Globaler EventBus ---
const listeners = new Map();
/**
* Abonniert ein benanntes Event
*/
export function on(eventName, callback) {
if (!listeners.has(eventName)) listeners.set(eventName, []);
listeners.get(eventName).push(callback);
// Unsubscribe
return () => {
const arr = listeners.get(eventName);
if (arr) listeners.set(eventName, arr.filter(fn => fn !== callback));
};
}
/**
* Sendet ein benanntes Event mit Payload
*/
export function emit(eventName, payload) {
const arr = listeners.get(eventName);
if (arr) arr.forEach(fn => fn(payload));
}
// --- 2. ActionDispatcher ---
const actionListeners = new Set();
/**
* Action registrieren (globaler Listener für alle Aktionen)
*/
export function registerActionListener(callback) {
actionListeners.add(callback);
return () => actionListeners.delete(callback);
}
/**
* Aktion ausführen
*/
export function dispatchAction(type, payload = {}) {
actionListeners.forEach(fn => fn({ type, payload }));
}