You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Read-only reactive element arrays with array-like interface:
120
+
`all()` returns `Memo<E[]>` — a lazily observed collection of elements:
120
121
121
122
```typescript
122
123
// Creation
123
-
({ all }) => ({ items: all('.item') }) // In UI query, will be ui.items
124
-
const items =createCollection(parent, '.item') // Elsewhere with arbitrary parent
124
+
({ all }) => ({ items: all('.item') }) // In UI query, will be ui.items
125
+
const items =createElementsMemo(parent, '.item')// Elsewhere with arbitrary parent
125
126
126
127
// Access
127
-
items.get() // Get current elements
128
-
items.length// Reactive length
129
-
items[0] // Index access
130
-
items.on('add', fn) // Listen for additions
131
-
items.on('remove', fn) // Listen for removals
128
+
items.get() // Get current elements array
129
+
items.get().length// Current count
130
+
items.get()[0] // Index access
132
131
```
133
132
133
+
The `MutationObserver` backing the memo activates lazily — only when the memo is read from within a reactive effect. This avoids unnecessary observation overhead for memos that aren't actively consumed.
- Change: small refactors that preserve exported API in `index.ts` and `.d.ts` files.
47
48
- Change: add or update examples in `examples/` to demonstrate new or changed behavior.
48
-
- Avoid: breaking changes to public exports without updating `index.ts`/ `index.dev.ts`and re-building (`bun run build:dev`).
49
+
- Avoid: breaking changes to public exports without updating `index.ts` and re-building (`bun run build`).
49
50
- Avoid: changing the custom element registration pattern (i.e., calling `customElements.define`) in a way that prevents `getHelpers` dependency detection.
0 commit comments