Find All Items Async
Asynchronously retrieves all items matching the specified criteria, supporting the same search strategies as findAll.
findAllAsync()
Asynchronously retrieves all items matching the specified criteria, supporting the same search strategies as findAll.
Signature
async findAllAsync(
supplier: () => Promise<T[]>,
matcher: string | number,
keySelector: KeySelector<T>,
options?: Omit<FindOptions<T>, 'data'>
): Promise<T[]>Parameters
| Parameter | Type | Description |
|---|---|---|
supplier | () => Promise<T[]> | Async function providing the dataset. |
matcher | string | number | Value to match against. |
keySelector | KeySelector<T> | Property name or value extractor function. |
options | Omit<FindOptions<T>, 'data'> | Search configuration options (excluding data). |
Returns
Promise<T[]> — Array of all matching items (empty if none found).
Description
This method provides an asynchronous interface to findAll, with identical search behavior but with support for:
- Promise-based data loading.
- Dynamic dataset updates.
- Asynchronous data sources.
Example Usage
import { Finder } from 'toolbox-x';
interface Product {
id: number;
name: string;
category: string;
}
const productFinder = new Finder<Product>([]);
// Basic Usage
const products = await productFinder.findAllAsync(
async () => [
{ id: 1, name: 'Laptop', category: 'electronics' },
{ id: 2, name: 'Shirt', category: 'apparel' }
],
'electronics',
'category'
);
console.log(products);Behavior
- Data Loading: First awaits the supplier function.
- Search Execution: Delegates to
findAllwith the resolved data. - Result Handling: Returns all matches (empty array if none).
Notes
- Inherits all search behavior from
findAll. - Supports the same caching and matching options.
- Automatically handles promise resolution.
- Rejects if supplier throws an error.
Last updated: Mon, Jun 15, 2026 06:09:51AM (UTC)
