Parallel Queries
Fasq is designed to handle multiple concurrent queries efficiently. When you use multiple QueryBuilder widgets in the same screen, they fetch in parallel automatically.
Usage
Simply use multiple query widgets side-by-side (e.g., in a Column).
Column(
children: [
QueryBuilder<User>(
queryKey: 'user'.toQueryKey(),
builder: /* ... */,
),
QueryBuilder<List<Post>>(
queryKey: 'posts'.toQueryKey(),
builder: /* ... */,
),
],
)How It Works
- Independent Execution: Each query runs its own async operation.
- Non-Blocking: One slow query does not stop the others from loading.
- Deduplication: If two components request the same key, only one network request is made.
Examples
Dynamic Parallel Queries
If you need to fetch a dynamic list of items (e.g. valid IDs), mapping them to queries works seamlessly.
// Fetching multiple posts by ID in parallel
Column(
children: postIds.map((id) =>
QueryBuilder(
queryKey: 'post:$id'.toQueryKey(),
queryFn: () => api.fetchPost(id),
builder: (context, state) => PostTile(state.data),
)
).toList(),
)Last updated on