a reactive (signals based) hypermedia web framework (wip)
stormlightlabs.github.io/volt/
hypermedia
frontend
signals
1---
2version: 1.0
3updated: 2025-10-18
4---
5
6# volt.d
7
8Context object available to all bindings
9
10## CleanupFunction
11
12```typescript
13() => void
14```
15
16## Scope
17
18```typescript
19Record<string, unknown>
20```
21
22## BindingContext
23
24Context object available to all bindings
25
26```typescript
27{ element: Element; scope: Scope; cleanups: CleanupFunction[] }
28```
29
30## PluginContext
31
32Context object provided to plugin handlers.
33Contains utilities and references for implementing custom bindings.
34
35### Members
36
37- **element**: `Element`
38 The DOM element the plugin is bound to
39- **scope**: `Scope`
40 The scope object containing signals and data
41- **lifecycle**: `PluginLifecycle`
42 Lifecycle hooks for plugin-specific mount/unmount behavior
43
44## PluginHandler
45
46Plugin handler function signature.
47Receives context and the attribute value, performs binding setup.
48
49```typescript
50(context: PluginContext, value: string) => void
51```
52
53## Signal
54
55A reactive primitive that notifies subscribers when its value changes.
56
57## ComputedSignal
58
59A computed signal that derives its value from other signals.
60
61## StorageAdapter
62
63Storage adapter interface for custom persistence backends
64
65## ChargedRoot
66
67Information about a mounted Volt root after charging
68
69element: The root element that was mounted
70scope: The reactive scope created for this root
71cleanup: Cleanup function to unmount this root
72
73```typescript
74{ element: Element; scope: Scope; cleanup: CleanupFunction }
75```
76
77## ChargeResult
78
79Result of charging Volt roots
80
81roots: Array of all charged roots
82cleanup: Cleanup function to unmount all roots
83
84```typescript
85{ roots: ChargedRoot[]; cleanup: CleanupFunction }
86```
87
88## Dep
89
90```typescript
91{ get: () => unknown; subscribe: (callback: (value: unknown) => void) => () => void }
92```
93
94## AsyncEffectOptions
95
96Options for configuring async effects
97
98### Members
99
100- **abortable**: `boolean`
101 Enable automatic AbortController integration.
102When true, provides an AbortSignal to the effect function for canceling async operations.
103- **debounce**: `number`
104 Debounce delay in milliseconds.
105Effect execution is delayed until this duration has passed without dependencies changing.
106- **throttle**: `number`
107 Throttle delay in milliseconds.
108Effect execution is rate-limited to at most once per this duration.
109- **onError**: `(error: Error, retry: () => void) => void`
110 Error handler for async effect failures.
111Receives the error and a retry function.
112- **retries**: `number`
113 Number of automatic retry attempts on error.
114Defaults to 0 (no retries).
115- **retryDelay**: `number`
116 Delay in milliseconds between retry attempts.
117Defaults to 0 (immediate retry).
118
119## AsyncEffectFunction
120
121Async effect function signature.
122Receives an optional AbortSignal when abortable option is enabled.
123Can return a cleanup function or a Promise that resolves to a cleanup function.
124
125```typescript
126(signal?: AbortSignal) => Promise<void | (() => void)>
127```
128
129## LifecycleHookCallback
130
131Lifecycle hook callback types
132
133```typescript
134() => void
135```
136
137## MountHookCallback
138
139```typescript
140(root: Element, scope: Scope) => void
141```
142
143## UnmountHookCallback
144
145```typescript
146(root: Element) => void
147```
148
149## ElementMountHookCallback
150
151```typescript
152(element: Element, scope: Scope) => void
153```
154
155## ElementUnmountHookCallback
156
157```typescript
158(element: Element) => void
159```
160
161## BindingHookCallback
162
163```typescript
164(element: Element, bindingName: string) => void
165```
166
167## GlobalHookName
168
169Lifecycle hook names
170
171```typescript
172"beforeMount" | "afterMount" | "beforeUnmount" | "afterUnmount"
173```
174
175## PluginLifecycle
176
177Extended plugin context with lifecycle hooks
178
179### Members
180
181- **onMount**: `(callback: LifecycleHookCallback) => void`
182 Register a callback to run when the plugin is initialized for an element
183- **onUnmount**: `(callback: LifecycleHookCallback) => void`
184 Register a callback to run when the element is being unmounted
185- **beforeBinding**: `(callback: LifecycleHookCallback) => void`
186 Register a callback to run before the binding is created
187- **afterBinding**: `(callback: LifecycleHookCallback) => void`
188 Register a callback to run after the binding is created