13 lines
560 B
TypeScript
13 lines
560 B
TypeScript
// Allowed: one bulk request, then per-row work is local mapping only.
|
|
type Gateway = { list(filters: { limit: number }): Promise<readonly { id: string }[]> };
|
|
|
|
export async function loadPage(gateway: Gateway) {
|
|
const rows = await gateway.list({ limit: 100 });
|
|
return rows.map((row) => ({ ...row, label: row.id.toUpperCase() }));
|
|
}
|
|
|
|
export function bindHandlers(gateway: Gateway, ids: readonly string[]) {
|
|
// Declaring a function per row is fine; it dispatches only when a user acts.
|
|
return ids.map((id) => () => gateway.list({ limit: id.length }));
|
|
}
|