Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

toResource.md

45 lines1.4 KB

1---
2id: toResource
3title: toResource
4---
5​
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7​
8```ts
9function toResource<TValue>(query: QueryResourceSource<TValue>): QueryResource<TValue>;
10```
11​
12Defined in: [packages/angular-query/src/query-resource.ts:41](https://github.com/TanStack/query/blob/main/packages/angular-query/src/query-resource.ts#L41)
13​
14Converts an Angular Query result into Angular's Resource interface.
15​
16Call this function once and reuse the returned resource.
17​
18## Type Parameters
19​
20### TValue
21​
22`TValue`
23​
24## Parameters
25​
26### query
27​
28`QueryResourceSource`\<`TValue`\>
29​
30An Angular Query or infinite-query result.
31​
32## Returns
33​
34[`QueryResource`](../interfaces/QueryResource.md)\<`TValue`\>
35​
36A Resource-compatible view of the query result.
37​
38<a id="result-properties"></a>
39​
40### Result properties
41​
42| Property | Modifier | Type | Description | Overrides |
43| ------ | ------ | ------ | ------ | ------ |
44| <a id="result-property-reload"></a> `reload` | `public` | () => `boolean` | Requests a new query fetch only when the current query data is stale. Used for compatibility with Angular APIs that might want to reload a resource, like Signal Forms' validateAsync resource interface. | - |
45| <a id="result-property-snapshot"></a> `snapshot` | `readonly` | `Signal`\<`ResourceSnapshot`\<`TValue`\>\> | The current query state as a single snapshot. | `Resource.snapshot` |