select method

Future<FetchStrategy<Input, Output>> select(
  1. Input input
)

Returns the first strategy that can handle input.

Throws StateError if no strategy can handle input.

Implementation

Future<FetchStrategy<Input, Output>> select(Input input) async {
  for (final candidate in _candidates) {
    if (await candidate.canHandle(input)) {
      return candidate;
    }
  }
  throw StateError(
    'No FetchStrategy can handle input: $input. '
    'Registered strategies: ${_candidates.map((s) => s.name).join(', ')}',
  );
}