load method

Future<Player> load(
  1. String id
)

Resolves one player, batched with every other load in the same window.

Throws PlayerNotFoundException if the id matches no player, or the underlying transport error if the batch request fails: the same outcomes a direct single lookup produces, so the cache above is unaware it was batched.

Implementation

Future<Player> load(String id) {
  final completer = Completer<Player>();
  _pending.putIfAbsent(id, () => []).add(completer);
  _timer ??= Timer(_window, _flush);
  return completer.future;
}