Yurba.js / @yurbajs/rest / BatchRequest
Class: BatchRequest
Batch request handler for parallel API calls
Constructors
Constructor
new BatchRequest():
BatchRequest
Returns
BatchRequest
Methods
add()
add<
T>(key,promise):BatchRequest
Add a request to the batch
Type Parameters
T
T
Parameters
key
string
Unique identifier for the request
promise
Promise<T>
Promise to execute
Returns
BatchRequest
BatchRequest instance for chaining
clear()
clear():
void
Clear all requests from the batch
Returns
void
execute()
execute<
T>():Promise<T>
Execute all requests in parallel
Type Parameters
T
T extends Record<string, any>
Returns
Promise<T>
Object with results keyed by request names
Throws
Error if any request fails
executeSettled()
executeSettled<
T>():Promise<T>
Execute all requests and return results even if some fail
Type Parameters
T
T extends Record<string, any>
Returns
Promise<T>
Object with results or errors keyed by request names
getKeys()
getKeys():
string[]
Get all request keys
Returns
string[]
isEmpty()
isEmpty():
boolean
Check if batch has any requests
Returns
boolean
size()
size():
number
Get the number of requests in the batch
Returns
number