-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Angular v19+ pending tasks and lazy derived signal proxy initialization #9986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
4579364
7951412
d7e8d66
0edde05
1438a89
e9439a5
2df8983
a9adba6
ffb096e
c1bc243
c727bc7
060f9ac
e7bb141
800311b
0fd6dbd
1dad967
b31faf7
608f898
f768ce5
0b9b1a7
85c37fd
03f8a7d
3528b4b
00ba5b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@tanstack/angular-query-experimental': minor | ||
| --- | ||
|
|
||
| require Angular v19+ and use Angular component effect scheduling |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -35,9 +35,9 @@ const result = injectQuery(() => ({ | |||||||||||||||||
| instantaneously while they are also re-fetched invisibly in the | ||||||||||||||||||
| background. | ||||||||||||||||||
| </p> | ||||||||||||||||||
| @if (query.status() === 'pending') { | ||||||||||||||||||
| @if (query.isPending()) { | ||||||||||||||||||
| <div>Loading...</div> | ||||||||||||||||||
| } @else if (query.status() === 'error') { | ||||||||||||||||||
| } @else if (query.isError()) { | ||||||||||||||||||
| <div>Error: {{ query.error().message }}</div> | ||||||||||||||||||
| } @else { | ||||||||||||||||||
| <!-- 'data' will either resolve to the latest page's data --> | ||||||||||||||||||
|
|
@@ -68,6 +68,10 @@ const result = injectQuery(() => ({ | |||||||||||||||||
| </div> | ||||||||||||||||||
| `, | ||||||||||||||||||
| }) | ||||||||||||||||||
|
|
||||||||||||||||||
| @Component({ | ||||||||||||||||||
| // ... | ||||||||||||||||||
| }) | ||||||||||||||||||
| export class PaginationExampleComponent { | ||||||||||||||||||
|
Comment on lines
+71
to
75
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate There's already a complete 🔎 Proposed fix </div>
`,
})
-
-@Component({
- // ...
-})
export class PaginationExampleComponent {📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| page = signal(0) | ||||||||||||||||||
| queryClient = inject(QueryClient) | ||||||||||||||||||
|
|
@@ -83,7 +87,7 @@ export class PaginationExampleComponent { | |||||||||||||||||
| effect(() => { | ||||||||||||||||||
| // Prefetch the next page! | ||||||||||||||||||
| if (!this.query.isPlaceholderData() && this.query.data()?.hasMore) { | ||||||||||||||||||
| this.#queryClient.prefetchQuery({ | ||||||||||||||||||
| this.queryClient.prefetchQuery({ | ||||||||||||||||||
| queryKey: ['projects', this.page() + 1], | ||||||||||||||||||
| queryFn: () => lastValueFrom(fetchProjects(this.page() + 1)), | ||||||||||||||||||
| }) | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -17,6 +17,9 @@ replace: | |||||
| [//]: # 'Example' | ||||||
|
|
||||||
| ```ts | ||||||
| @Component({ | ||||||
| // ... | ||||||
| }) | ||||||
| export class AppComponent { | ||||||
| // The following queries will execute in parallel | ||||||
| usersQuery = injectQuery(() => ({ queryKey: ['users'], queryFn: fetchUsers })) | ||||||
|
|
@@ -38,11 +41,15 @@ TanStack Query provides `injectQueries`, which you can use to dynamically execut | |||||
| [//]: # 'DynamicParallelIntro' | ||||||
| [//]: # 'Example2' | ||||||
|
|
||||||
| > IMPORTANT: `injectQueries` is experimental and is provided in it's own entry point | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor grammatical correction needed. Change "it's own entry point" to "its own entry point" (possessive form, not contraction). 🔎 Proposed fix-> IMPORTANT: `injectQueries` is experimental and is provided in it's own entry point
+> IMPORTANT: `injectQueries` is experimental and is provided in its own entry point📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| ```ts | ||||||
| @Component({ | ||||||
| // ... | ||||||
| }) | ||||||
| export class AppComponent { | ||||||
| users = signal<Array<User>>([]) | ||||||
|
|
||||||
| // Please note injectQueries is under development and this code does not work yet | ||||||
| userQueries = injectQueries(() => ({ | ||||||
| queries: users().map((user) => { | ||||||
| return { | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect data access pattern in
injectQueriesexample.Line 43 uses
this.userIds()butuserIdsis the query result object frominjectQuery, not a signal of the data. To access the selected user IDs, it should bethis.userIds.data().🔎 Proposed fix
// Then get the users messages userQueries = injectQueries(() => ({ - queries: (this.userIds() ?? []).map((userId) => ({ + queries: (this.userIds.data() ?? []).map((userId) => ({ queryKey: ['user', userId], queryFn: () => getUserById(userId), })), }))📝 Committable suggestion
🤖 Prompt for AI Agents