lib/
├── common/
│ ├── dispatcher.svelte.ts # Central event dispatcher
│ ├── types.ts # Shared type definitions
│ └── DispatcherDebug.svelte # Debug UI component
│
└── domains/
├── a/
│ ├── actions/ # Domain A action creators
│ └── stores/ # Domain A state management
│
└── b/
├── actions/ # Domain B action creators
└── stores/ # Domain B state management
UI → Action Creator → Dispatcher → Store → UI Update
<button on:click={aActions.increment}>
<p>Value: {aStore.value}</p>
increment: () => dispatcher.dispatch({ type: 'A/INCREMENT' })
class Store {
private state = $state(...)
double = $derived(...)
}