requireComposable static method

void requireComposable({
  1. required ReadyValidContract provider,
  2. required ReadyValidContract consumer,
  3. required String providerName,
  4. required String consumerName,
})

Rejects a direct provider-to-consumer composition that can form a combinational valid/ready cycle.

This is a construction-time check rather than a Dart type-system check: interface contracts are values carried by generic interface instances. provider describes the valid behavior at the boundary and consumer describes the ready behavior at that same boundary.

Implementation

static void requireComposable({
  required ReadyValidContract provider,
  required ReadyValidContract consumer,
  required String providerName,
  required String consumerName,
}) {
  if (provider.mayFormDependencyCycleWith(consumer)) {
    throw ArgumentError(
      'Ready/valid composition from $providerName to '
      '$consumerName can form a combinational dependency cycle: provider '
      'valid may depend on ready while consumer ready may depend on valid. '
      'Insert a storage stage or use independent boundary contracts.',
    );
  }
}