RequestCoalescer class

Coalesces identical inflight requests into a single network call.

When multiple callers request the same RequestKey while a request is already in flight, they all receive the same response from the single network call.

This is the authority for coalescing behavior. FetchState.activeRequests is derived from this for observability/UI.

Constructors

RequestCoalescer({void onInflightChanged(String canonical, bool isInflight)?, void onCoalesced(String canonical)?})

Properties

hashCode int
The hash code for this object.
no setterinherited
inflightCount int
Get count of inflight requests.
no setter
inflightKeys Set<String>
Get current inflight canonical keys (for state sync).
no setter
onCoalesced → void Function(String canonical)?
Callback when a request coalesces with an existing inflight request.
final
onInflightChanged → void Function(String canonical, bool isInflight)?
Callback when inflight status changes (for state sync).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

cancelAll(String reason) → void
Cancel all inflight requests with a reason.
clear() → void
Cancel all inflight requests.
coalesce(RequestKey key, Future<Response> execute()) Future<CoalesceResult>
Execute a request, coalescing with any existing inflight request.
getInflight(RequestKey key) Future<Response>?
Get the inflight future for a key, if any.
isInflight(RequestKey key) bool
Check if a request is currently inflight.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
takeCoalescedCount() int
Get and reset the coalesced counter. Used for stats tracking - call before and after a request to detect coalescing.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited