sequence<T> method

void sequence<T>(
  1. ScopeKey<T> key,
  2. T factory()
)

Injects a generated value into the Scope.

The sequence's factory method is called each time use for the key is called.

The difference between single and sequence is that for a single the factory method is only called once where as the sequences factory method is called each time use for the sequence's key is called.

The sequence factory method is NOT called when the run method is called.

Implementation

void sequence<T>(ScopeKey<T> key, T Function() factory) {
  if (_sequences.containsKey(key)) {
    throw DuplicateDependencyException(key);
  }
  value<dynamic>(key, factory);
}