Tutorials
Connect a Repository to UseCase Forge
Translate committed Repository data into regular Commands without coupling either package.
v0.1.0-dev.1Advancedark_data_layer
Connect a Repository to UseCase Forge
The binding belongs to the Application layer because it decides which data change becomes which Command.
dart
final class CatalogBinding {
CatalogBinding(CatalogRepository repository, CatalogUseCase useCase)
: _subscription = repository.stream.listen(
(data) => useCase.add(CatalogChanged(data)),
);
final StreamSubscription<CatalogData> _subscription;
Future<void> close() => _subscription.cancel();
}
Listening directly processes the replayed current value. Use stream.skip(1) when only future commits should submit commands.
The listener performs no asynchronous business work. UseCase Forge remains responsible for admission, debounce or throttle, execution grouping, cancellation, errors, history, and diagnostics.
Close the binding before the UseCase, then close the Repository and its DataSources.