Skip to content

Commit f423b66

Browse files
committed
Add changeset
1 parent ad24cd4 commit f423b66

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

.changeset/cute-falcons-wear.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
"@tanstack/solid-db": minor
3+
---
4+
5+
Update solid-db to enable suspense support.
6+
You can now run do
7+
8+
```tsx
9+
// Use Suspense boundaries
10+
const todosQuery = useLiveQuery((q) => q.from({ todos: todoCollection }))
11+
12+
return (
13+
<>
14+
{/* Status and other getters don't trigger Suspense */}
15+
<div>Status {todosQuery.status}</div>
16+
<div>Loading {todosQuery.isLoading ? "yes" : "no"}</div>
17+
18+
<Suspense fallback={<div>Loading...</div>}>
19+
<For each={todosQuery()}>
20+
{(todo) => <li key={todo.id}>{todo.text}</li>}
21+
</For>
22+
</Suspense>
23+
</>
24+
)
25+
```
26+
27+
All values returned from useLiveQuery are now getters, so no longer need to be called as functions. This is a breaking change. This is to match how createResource works, and everything still stays reactive.
28+
29+
```tsx
30+
const todos = useLiveQuery(() => existingCollection)
31+
32+
const handleToggle = (id) => {
33+
// Can now access collection directly
34+
todos.collection.update(id, (draft) => {
35+
draft.completed = !draft.completed
36+
})
37+
}
38+
39+
return (
40+
<>
41+
{/* Status and other getters don't trigger Suspense */}
42+
<div>Status {todos.status}</div>
43+
<div>Loading {todos.isLoading ? "yes" : "no"}</div>
44+
<div>Ready {todos.isReady ? "yes" : "no"}</div>
45+
<div>Idle {todos.isIdle ? "yes" : "no"}</div>
46+
<div>Error {todos.isError ? "yes" : "no"}</div>
47+
</>
48+
)
49+
```

0 commit comments

Comments
 (0)