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

toResource.md

48 lines1.5 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:44](https://github.com/TanStack/query/blob/main/packages/angular-query/src/query-resource.ts#L44)
13​
14Converts an Angular Query result into Angular's Resource interface.
15​
16Warning: experimental feature. The API may change in minor and patch releases.
17Pin your package version to an exact version when using this feature.
18​
19Call this function once and reuse the returned resource.
20​
21## Type Parameters
22​
23### TValue
24​
25`TValue`
26​
27## Parameters
28​
29### query
30​
31`QueryResourceSource`\<`TValue`\>
32​
33An Angular Query or infinite-query result.
34​
35## Returns
36​
37[`QueryResource`](../interfaces/QueryResource.md)\<`TValue`\>
38​
39A Resource-compatible view of the query result.
40​
41<a id="result-properties"></a>
42​
43### Result properties
44​
45| Property | Modifier | Type | Description | Overrides |
46| ------ | ------ | ------ | ------ | ------ |
47| <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. | - |
48| <a id="result-property-snapshot"></a> `snapshot` | `readonly` | `Signal`\<`ResourceSnapshot`\<`TValue`\>\> | The current query state as a single snapshot. | `Resource.snapshot` |