Replies: 3 comments 5 replies
|
not sure if looking at the type signature of query/packages/angular-query-experimental/src/inject-queries.ts Lines 204 to 214 in 3bf9268 |
|
ngneat/query has a very useful helper function https://github.com/ngneat/query?tab=readme-ov-file#intersectresults-1. Their version is a lot more useful than the |
|
yeah I wouldn't reach for honestly the activeUser = computed(() => {
const user = this.user.data();
const roles = this.roles.data();
if (!user || !roles) return undefined;
return this.toUser(user, roles);
});@if (activeUser(); as user) {
<div>roles: {{ user.roles.length }}</div>
}both queries stay independent (own key, own cache, own refetch), computed just reads their signals and re-runs when either changes. if you want combined loading/error instead of the single null check you can pull those out too: isLoading = computed(() => this.user.isLoading() || this.roles.isLoading());works today without touching the experimental stuff. can swap to combine later once it's stable for angular. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I have two separate queries using
@tanstack/angular-query:I want to keep these queries separate, but in the UI I want to consume them as one combined object, e.g.:
Ideally something like:
But I can't figure out how to combine the results like this.
I also tried a computed signal, but
computed()returnsnulluntil both queries load, and I'd prefer to stay within the TanStack Query API:Is there a built-in way in TanStack Query for Angular to derive/merge the results of two queries into one object (similar to
injectQueries + select), while still keeping both queries independent?All reactions