updated 2026-11-26·3 min read
Reactive EventBus & State Pipeline
How Noether coordinates inter-subsystem events through a centralized typed EventBus and isolates React state across partitioned Zustand stores.
If extensions reach straight into app stores, disabling one leaves dangling listeners and broken state behind, and putting everything in one giant React store makes every keystroke re-render the file tree. Noether routes cross-subsystem events through a typed EventBus and splits UI state into focused Zustand stores.
1. The Typed EventBus Contract
Extensions and UI panels talk through EventBus (src/core/events/EventBus.ts, typed by WorkspaceEvents in src/core/events/events.ts) instead of mutating native stores directly:
┌─────────────────────────────────────────────────────────────┐
│ Event Producers │
│ • Document Store (save/delete) • Workspace Tabs (switch) │
│ • Extension Manager (lifecycle)• Settings (reset) │
└──────────────────────────────┬──────────────────────────────┘
│ Dispatches Typed Event
▼
┌─────────────────────────────────────────────────────────────┐
│ Noether EventBus Hub │
│ document:saved • document:deleted • vault:loaded • ... │
└───────────────┬───────────────────────────────┬─────────────┘
│ │
▼ ▼
┌───────────────────────────────┐ ┌───────────────────────────┐
│ Core Database Manager │ │ Community Extensions │
│ Cascade cleanup on delete │ │ Word Counter, Sync, ... │
└───────────────────────────────┘ └───────────────────────────┘
Core Lifecycle Events
Standard lifecycle events emitted on EventBus:
| Event Name | Payload | Emitted When |
|---|---|---|
document:opened | { id: string, title: string } | A document is opened in the workspace. |
document:saved | { id: string, title: string } | A document finishes saving to storage. |
document:deleted | { id: string, title?: string } | A document is deleted or moved to trash. |
document:renamed | { id: string, oldTitle: string, newTitle: string } | A document title is renamed. |
vault:loaded | { path: string, name: string } | The active vault finishes loading and indexing. |
vault:changed | { path: string, name: string } | The user switches to a different vault. |
tab:changed | { activeTabId: string | null } | Active tab selection changes. |
view:mode-changed | { mode: string } | Main view mode changes (e.g. document → graph). |
settings:defaults-restored | { scope: 'all' | string } | Host preferences and extension settings are reset to defaults. |
2. Inversion of Control & Extension Subscriptions
When an extension needs to react to note changes, it subscribes through this.onEvent() (or this.registerEvent(this.app.events.on(...))) during onload():
import { Extension } from 'noether';
export default class WordCounterExtension extends Extension {
async onload(): Promise<void> {
this.onEvent('document:saved', ({ id, title }) => {
this.updateWordCount(id, title);
});
}
}
this.onEvent() wraps this.registerDisposable(), tracking the subscription inside the extension’s disposables list. When an extension is disabled or uninstalled, Extension.unload() runs onunload() and then disposes every tracked listener automatically so nothing leaks.
3. Zustand Store Partitioning
Noether splits application state across eight focused Zustand stores under src/store/ instead of one monolithic global store:
documentStore: Open document catalog, active document buffer, headings, backlinks, tags, global tasks, and save/sync actions.workspaceStore: Split-pane tab layout, sidebar visibility, active main view mode, modal open flags, and status bar metrics.settingsStore: Persistent user preferences (theme, accent color, typography, default view modes, keybindings).sidebarDockStore: Docked sidebar view items and split-pane docking state.contextMenuStore: Active floating context menu items and screen coordinates.dragDropStore: Active drag payload and drop target state across file tree and tabs.fileClipboardStore: Cut/copied document and folder selections for file tree operations.fileHistoryStore: Undo/redo stack for file-level move, rename, and delete actions.
Splitting transient UI state (context menus, drag previews, status counts) out of documentStore stops typing keystrokes from re-rendering unrelated panels.