Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Contains reactive signals for the query state and data.

```ts
collection: Signal<
| Collection<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }, string | number, {
}, StandardSchemaV1<unknown, unknown>, { [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }>
| Collection<{ [K in string | number | symbol]: ResultValue<TContext>[K] }, string | number, {
}, StandardSchemaV1<unknown, unknown>, { [K in string | number | symbol]: ResultValue<TContext>[K] }>
| null>;
```

Expand Down Expand Up @@ -108,7 +108,7 @@ A signal indicating whether the collection is ready
### state

```ts
state: Signal<Map<string | number, { [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }>>;
state: Signal<Map<string | number, { [K in string | number | symbol]: ResultValue<TContext>[K] }>>;
```

Defined in: [index.ts:34](https://github.com/TanStack/db/blob/main/packages/angular-db/src/index.ts#L34)
Expand Down
30 changes: 15 additions & 15 deletions docs/framework/react/reference/functions/useLiveQuery.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Object with reactive data, state, and status information
#### collection

```ts
collection: Collection<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }, string | number, {
collection: Collection<{ [K in string | number | symbol]: ResultValue<TContext>[K] }, string | number, {
}>;
```

Expand Down Expand Up @@ -93,7 +93,7 @@ isReady: boolean;
#### state

```ts
state: Map<string | number, { [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }>;
state: Map<string | number, { [K in string | number | symbol]: ResultValue<TContext>[K] }>;
```

#### status
Expand Down Expand Up @@ -202,8 +202,8 @@ Object with reactive data, state, and status information

```ts
collection:
| Collection<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }, string | number, {
}, StandardSchemaV1<unknown, unknown>, { [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }>
| Collection<{ [K in string | number | symbol]: ResultValue<TContext>[K] }, string | number, {
}, StandardSchemaV1<unknown, unknown>, { [K in string | number | symbol]: ResultValue<TContext>[K] }>
| undefined;
```

Expand Down Expand Up @@ -253,7 +253,7 @@ isReady: boolean;

```ts
state:
| Map<string | number, { [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }>
| Map<string | number, { [K in string | number | symbol]: ResultValue<TContext>[K] }>
| undefined;
```

Expand Down Expand Up @@ -344,7 +344,7 @@ Create a live query using a query function
#### queryFn

(`q`) =>
\| `LiveQueryCollectionConfig`\<`TContext`, \{ \[K in string \| number \| symbol\]: (TContext\["result"\] extends object ? any\[any\] : TContext\["hasJoins"\] extends true ? TContext\["schema"\] : TContext\["schema"\]\[TContext\["fromSourceName"\]\])\[K\] \} & `object`\>
\| `LiveQueryCollectionConfig`\<`TContext`, `RootQueryResult`\<`TContext`\>\>
\| `null`
\| `undefined`

Expand All @@ -366,8 +366,8 @@ Object with reactive data, state, and status information

```ts
collection:
| Collection<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }, string | number, {
}, StandardSchemaV1<unknown, unknown>, { [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }>
| Collection<{ [K in string | number | symbol]: ResultValue<TContext>[K] }, string | number, {
}, StandardSchemaV1<unknown, unknown>, { [K in string | number | symbol]: ResultValue<TContext>[K] }>
| undefined;
```

Expand Down Expand Up @@ -417,7 +417,7 @@ isReady: boolean;

```ts
state:
| Map<string | number, { [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }>
| Map<string | number, { [K in string | number | symbol]: ResultValue<TContext>[K] }>
| undefined;
```

Expand Down Expand Up @@ -690,7 +690,7 @@ Create a live query using a query function

(`q`) =>
\| `QueryBuilder`\<`TContext`\>
\| `LiveQueryCollectionConfig`\<`TContext`, \{ \[K in string \| number \| symbol\]: (TContext\["result"\] extends object ? any\[any\] : TContext\["hasJoins"\] extends true ? TContext\["schema"\] : TContext\["schema"\]\[TContext\["fromSourceName"\]\])\[K\] \} & `object`\>
\| `LiveQueryCollectionConfig`\<`TContext`, `RootQueryResult`\<`TContext`\>\>
\| `Collection`\<`TResult`, `TKey`, `TUtils`, `StandardSchemaV1`\<`unknown`, `unknown`\>, `TResult`\>
\| `null`
\| `undefined`
Expand All @@ -714,8 +714,8 @@ Object with reactive data, state, and status information
```ts
collection:
| Collection<TResult, TKey, TUtils, StandardSchemaV1<unknown, unknown>, TResult>
| Collection<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }, string | number, {
}, StandardSchemaV1<unknown, unknown>, { [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }>
| Collection<{ [K in string | number | symbol]: ResultValue<TContext>[K] }, string | number, {
}, StandardSchemaV1<unknown, unknown>, { [K in string | number | symbol]: ResultValue<TContext>[K] }>
| undefined;
```

Expand Down Expand Up @@ -765,7 +765,7 @@ isReady: boolean;

```ts
state:
| Map<string | number, { [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }>
| Map<string | number, { [K in string | number | symbol]: ResultValue<TContext>[K] }>
| Map<TKey, TResult>
| undefined;
```
Expand Down Expand Up @@ -875,7 +875,7 @@ Object with reactive data, state, and status information
#### collection

```ts
collection: Collection<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }, string | number, {
collection: Collection<{ [K in string | number | symbol]: ResultValue<TContext>[K] }, string | number, {
}>;
```

Expand Down Expand Up @@ -924,7 +924,7 @@ isReady: boolean;
#### state

```ts
state: Map<string | number, { [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }>;
state: Map<string | number, { [K in string | number | symbol]: ResultValue<TContext>[K] }>;
```

#### status
Expand Down
61 changes: 61 additions & 0 deletions docs/framework/react/reference/functions/useLiveQueryEffect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
id: useLiveQueryEffect
title: useLiveQueryEffect
---

# Function: useLiveQueryEffect()

```ts
function useLiveQueryEffect<TRow, TKey>(config, deps): void;
```

Defined in: [useLiveQueryEffect.ts:30](https://github.com/TanStack/db/blob/main/packages/react-db/src/useLiveQueryEffect.ts#L30)

React hook for creating a reactive effect that fires handlers when rows
enter, exit, or update within a query result.

The effect is created on mount and disposed on unmount. If `deps` change,
the previous effect is disposed and a new one is created.

## Type Parameters

### TRow

`TRow` *extends* `object` = `Record`\<`string`, `unknown`\>

### TKey

`TKey` *extends* `string` \| `number` = `string` \| `number`

## Parameters

### config

`EffectConfig`\<`TRow`, `TKey`\>

### deps

`DependencyList` = `[]`

## Returns

`void`

## Example

```tsx
function ChatComponent() {
useLiveQueryEffect(
{
query: (q) => q.from({ msg: messages }).where(({ msg }) => eq(msg.role, 'user')),
skipInitial: true,
onEnter: async (event) => {
await generateResponse(event.value)
},
},
[]
)

return <div>...</div>
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Object with reactive data and state - data is guaranteed to be defined
#### collection

```ts
collection: Collection<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }, string | number, {
collection: Collection<{ [K in string | number | symbol]: ResultValue<TContext>[K] }, string | number, {
}>;
```

Expand All @@ -57,7 +57,7 @@ data: InferResultType<TContext>;
#### state

```ts
state: Map<string | number, { [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }>;
state: Map<string | number, { [K in string | number | symbol]: ResultValue<TContext>[K] }>;
```

### Throws
Expand Down Expand Up @@ -198,7 +198,7 @@ Object with reactive data and state - data is guaranteed to be defined
#### collection

```ts
collection: Collection<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }, string | number, {
collection: Collection<{ [K in string | number | symbol]: ResultValue<TContext>[K] }, string | number, {
}>;
```

Expand All @@ -211,7 +211,7 @@ data: InferResultType<TContext>;
#### state

```ts
state: Map<string | number, { [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }>;
state: Map<string | number, { [K in string | number | symbol]: ResultValue<TContext>[K] }>;
```

### Throws
Expand Down
1 change: 1 addition & 0 deletions docs/framework/react/reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ title: "@tanstack/react-db"

- [useLiveInfiniteQuery](functions/useLiveInfiniteQuery.md)
- [useLiveQuery](functions/useLiveQuery.md)
- [useLiveQueryEffect](functions/useLiveQueryEffect.md)
- [useLiveSuspenseQuery](functions/useLiveSuspenseQuery.md)
- [usePacedMutations](functions/usePacedMutations.md)
Loading