Clean project: remove test files, debug logs, and add documentation
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
/// Configuration de l'injection de dépendances pour le module Organisations
|
||||
library organisations_di;
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import '../data/repositories/organisation_repository.dart';
|
||||
import '../data/services/organisation_service.dart';
|
||||
import '../bloc/organisations_bloc.dart';
|
||||
|
||||
/// Configuration des dépendances du module Organisations
|
||||
class OrganisationsDI {
|
||||
static final GetIt _getIt = GetIt.instance;
|
||||
|
||||
/// Enregistre toutes les dépendances du module
|
||||
static void registerDependencies() {
|
||||
// Repository
|
||||
_getIt.registerLazySingleton<OrganisationRepository>(
|
||||
() => OrganisationRepositoryImpl(_getIt<Dio>()),
|
||||
);
|
||||
|
||||
// Service
|
||||
_getIt.registerLazySingleton<OrganisationService>(
|
||||
() => OrganisationService(_getIt<OrganisationRepository>()),
|
||||
);
|
||||
|
||||
// BLoC - Factory pour permettre plusieurs instances
|
||||
_getIt.registerFactory<OrganisationsBloc>(
|
||||
() => OrganisationsBloc(_getIt<OrganisationService>()),
|
||||
);
|
||||
}
|
||||
|
||||
/// Nettoie les dépendances du module
|
||||
static void unregisterDependencies() {
|
||||
if (_getIt.isRegistered<OrganisationsBloc>()) {
|
||||
_getIt.unregister<OrganisationsBloc>();
|
||||
}
|
||||
if (_getIt.isRegistered<OrganisationService>()) {
|
||||
_getIt.unregister<OrganisationService>();
|
||||
}
|
||||
if (_getIt.isRegistered<OrganisationRepository>()) {
|
||||
_getIt.unregister<OrganisationRepository>();
|
||||
}
|
||||
}
|
||||
|
||||
/// Obtient une instance du BLoC
|
||||
static OrganisationsBloc getOrganisationsBloc() {
|
||||
return _getIt<OrganisationsBloc>();
|
||||
}
|
||||
|
||||
/// Obtient une instance du service
|
||||
static OrganisationService getOrganisationService() {
|
||||
return _getIt<OrganisationService>();
|
||||
}
|
||||
|
||||
/// Obtient une instance du repository
|
||||
static OrganisationRepository getOrganisationRepository() {
|
||||
return _getIt<OrganisationRepository>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user