Recipes

Close the data graph safely

Stop producers before consumers and keep shared DataSource ownership in the Composition Root.

v1.1.0Advancedark_data_layer

Close the data graph safely

dart
await binding.close();
await useCase.close();
await repository.close();
await remoteSource.close();
await database.close();

The outer Composition Root owns shared sources. Override closeRepository() only for subscriptions or resources created by that Repository itself. Repeated repository.close() calls return the same Future and never repeat cleanup.