Version: 1.0.0 This guide explains how data flows through the framework and how its key components interact.
Eleva’s design emphasizes clarity, modularity, and performance.
Components are plain JavaScript objects that describe a UI segment:
template function - Returns HTML with interpolation placeholderssetup() function - Initializes state using reactive signals (optional)style function - Scoped CSS (optional)children object - Nested components (optional)Signals are reactive data holders that notify watchers when their values change, triggering re-renders of the affected UI.
Evaluates expressions in @events and :props attributes against the component context, enabling event binding and prop passing.
Compares the new HTML structure with the current DOM and patches only the parts that have changed, ensuring high performance without virtual DOM overhead.
Implements a publish-subscribe pattern to allow components to communicate by emitting and listening to custom events.
app.component()app.mount() creates a context (props, lifecycle hooks, emitter) and executes setup() to create reactive state${}) interpolate values directly@events and :props expressions@click) are bound during rendering[Component Registration]
│
▼
[Mounting & Context Creation]
│
▼
[setup() Execution → Creates Signals]
│
▼
[Template Function Produces HTML]
│
▼
onBeforeMount
│
▼
[Renderer: Diff → Patch DOM]
│
▼
[Process @events & :props]
│
▼
[Inject Scoped Styles]
│
▼
[Mount Child Components]
│
▼
onMount
│
▼
┌────────────────────────────────────────────┐
│ ↺ REACTIVE CYCLE │
├────────────────────────────────────────────┤
│ │
│ [Idle: Waiting for Signal Change] ◄───┐ │
│ │ │ │
│ ▼ │ │
│ [User Event / Signal Change / Emit] │ │
│ │ │ │
│ ▼ │ │
│ [queueMicrotask Batches Updates] │ │
│ │ │ │
│ ▼ │ │
│ [Template Re-evaluation] │ │
│ │ │ │
│ ▼ │ │
│ onBeforeUpdate │ │
│ │ │ │
│ ▼ │ │
│ [Renderer: Diff → Patch DOM] │ │
│ │ │ │
│ ▼ │ │
│ [Process @events & :props] │ │
│ │ │ │
│ ▼ │ │
│ onUpdate ────────────────────────┘ │
│ │
└────────────────────────────────────────────┘
For contributors or developers seeking a deeper understanding:
[Component Registration]
│
▼
[Mounting & Context Creation]
• props passed to context
• emitter reference (shared instance)
• signal factory function
│
▼
[setup() Execution]
• Creates signals via factory
• Returns state + lifecycle hooks
│
▼
[Template Function Produces HTML]
• Template literals ${} evaluated
• Returns HTML string
│
▼
─ onBeforeMount ─
│
▼
[Renderer: Diff → Patch]
• Two-pointer diffing algorithm
• Key-based reconciliation
• Minimal DOM mutations
│
▼
[TemplateEngine Processes]
• Evaluates @event expressions
• Binds event listeners to DOM
• Evaluates :prop expressions
│
▼
[Inject Scoped Styles]
│
▼
[Mount Child Components]
│
▼
─ onMount ─
│
▼
┌────────────────────────────────────────────────────┐
│ ↺ REACTIVE CYCLE │
├────────────────────────────────────────────────────┤
│ │
│ [Idle: Waiting for Signal Change] ◄──────┐ │
│ │ │ │
│ ┌───────────────────┼───────────────────┐ │ │
│ ▼ ▼ ▼ │ │
│ [User Event] [Signal.value = x] [emitter] │ │
│ │ │ │ │ │
│ └───────────────────┼───────────────────┘ │ │
│ ▼ │ │
│ [queueMicrotask Batching] │ │
│ • Multiple changes collapsed │ │
│ • Single render scheduled │ │
│ │ │ │
│ ▼ │ │
│ [Template Re-evaluation] │ │
│ │ │ │
│ ▼ │ │
│ ─ onBeforeUpdate ─ │ │
│ │ │ │
│ ▼ │ │
│ [Renderer: Diff → Patch] │ │
│ │ │ │
│ ▼ │ │
│ [TemplateEngine Processes] │ │
│ • Re-binds @events │ │
│ • Re-evaluates :props │ │
│ │ │ │
│ ▼ │ │
│ ─ onUpdate ──────────────────┘ │
│ │
└────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│ ELEVA DATA FLOW │
├─────────────────────────────────────────────────────────────┤
│ │
│ [Component Registration] │
│ │ │
│ ▼ │
│ [Mounting & Context Creation] │
│ │ │
│ ▼ │
│ [setup() Execution] ──► Returns { state, hooks } │
│ │ │
│ ▼ │
│ [template() Produces HTML] │
│ │ │
│ ▼ │
│ [onBeforeMount] │
│ │ │
│ ▼ │
│ [Renderer.patchDOM()] ──► Diff & patch changes │
│ │ │
│ ▼ │
│ [TemplateEngine] ──► Bind @events, eval :props │
│ │ │
│ ▼ │
│ [onMount] │
│ │ │
│ ▼ │
│ ┌─────────────────── ↺ REACTIVE CYCLE ───────────────────┐ │
│ │ │ │
│ │ [Idle: Waiting] ◄─────────────────────────────────┐ │ │
│ │ │ │ │ │
│ │ ▼ │ │ │
│ │ [User Interaction] ──► Event Handler │ │ │
│ │ │ │ │ │
│ │ ▼ │ │ │
│ │ [signal.value = newValue] │ │ │
│ │ │ │ │ │
│ │ ▼ │ │ │
│ │ [queueMicrotask batching] │ │ │
│ │ │ │ │ │
│ │ ▼ │ │ │
│ │ [template() Re-evaluation] │ │ │
│ │ │ │ │ │
│ │ ▼ │ │ │
│ │ [onBeforeUpdate] │ │ │
│ │ │ │ │ │
│ │ ▼ │ │ │
│ │ [Renderer.patchDOM()] │ │ │
│ │ │ │ │ │
│ │ ▼ │ │ │
│ │ [TemplateEngine] ──► Re-bind @events │ │ │
│ │ │ │ │ │
│ │ ▼ │ │ │
│ │ [onUpdate] ───────────────────────────────────────┘ │ │
│ │ │ │
│ └────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
| Benefit | Description |
|---|---|
| Modularity | Each component encapsulates its own logic and state |
| Efficiency | Only changed DOM parts are updated |
| Predictability | One-way data flow (state → template → DOM) |
| Extensibility | Clear separation of concerns enables plugins |
┌─────────────────────────────────────────────────────────────┐
│ Eleva (Core) │
│ │
│ ┌─────────┐ ┌────────────────┐ ┌──────────────────┐ │
│ │ Signal │◄──►│ TemplateEngine │◄──►│ Renderer │ │
│ └─────────┘ └────────────────┘ └──────────────────┘ │
│ │ │ │ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌───────────────────────────────────────────────────────┐ │
│ │ Component │ │
│ │ • setup() creates signals │ │
│ │ • template() uses TemplateEngine for @events/:props │ │
│ │ • Renderer patches DOM on signal changes │ │
│ └───────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────┐ │
│ │ Emitter │ ◄── Inter-component communication │
│ └─────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
| ← Components | Back to Main Docs | Plugin System → |