refactor: change singleton registrations to lazySingleton for improved performance
This commit is contained in:
@@ -33,7 +33,7 @@ class StaffHomeModule extends Module {
|
||||
);
|
||||
|
||||
// Presentation layer - Cubits
|
||||
i.addSingleton(
|
||||
i.addLazySingleton(
|
||||
() => HomeCubit(
|
||||
repository: i.get<HomeRepository>(),
|
||||
getProfileCompletion: i.get<GetProfileCompletionUseCase>(),
|
||||
|
||||
@@ -68,7 +68,7 @@ class StaffProfileModule extends Module {
|
||||
|
||||
// Presentation layer - Cubit as singleton to avoid recreation
|
||||
// BlocProvider will use this same instance, preventing state emission after close
|
||||
i.addSingleton<ProfileCubit>(
|
||||
i.addLazySingleton<ProfileCubit>(
|
||||
() => ProfileCubit(
|
||||
i.get<GetStaffProfileUseCase>(),
|
||||
i.get<SignOutStaffUseCase>(),
|
||||
|
||||
@@ -17,17 +17,17 @@ class FaqsModule extends Module {
|
||||
@override
|
||||
void binds(Injector i) {
|
||||
// Repository
|
||||
i.addSingleton<FaqsRepositoryInterface>(
|
||||
i.addLazySingleton<FaqsRepositoryInterface>(
|
||||
() => FaqsRepositoryImpl(),
|
||||
);
|
||||
|
||||
// Use Cases
|
||||
i.addSingleton(
|
||||
i.addLazySingleton(
|
||||
() => GetFaqsUseCase(
|
||||
i<FaqsRepositoryInterface>(),
|
||||
),
|
||||
);
|
||||
i.addSingleton(
|
||||
i.addLazySingleton(
|
||||
() => SearchFaqsUseCase(
|
||||
i<FaqsRepositoryInterface>(),
|
||||
),
|
||||
|
||||
@@ -25,29 +25,29 @@ class PrivacySecurityModule extends Module {
|
||||
@override
|
||||
void binds(Injector i) {
|
||||
// Repository
|
||||
i.addSingleton<PrivacySettingsRepositoryInterface>(
|
||||
i.addLazySingleton<PrivacySettingsRepositoryInterface>(
|
||||
() => PrivacySettingsRepositoryImpl(
|
||||
Modular.get<DataConnectService>(),
|
||||
),
|
||||
);
|
||||
|
||||
// Use Cases
|
||||
i.addSingleton(
|
||||
i.addLazySingleton(
|
||||
() => GetProfileVisibilityUseCase(
|
||||
i<PrivacySettingsRepositoryInterface>(),
|
||||
),
|
||||
);
|
||||
i.addSingleton(
|
||||
i.addLazySingleton(
|
||||
() => UpdateProfileVisibilityUseCase(
|
||||
i<PrivacySettingsRepositoryInterface>(),
|
||||
),
|
||||
);
|
||||
i.addSingleton(
|
||||
i.addLazySingleton(
|
||||
() => GetTermsUseCase(
|
||||
i<PrivacySettingsRepositoryInterface>(),
|
||||
),
|
||||
);
|
||||
i.addSingleton(
|
||||
i.addLazySingleton(
|
||||
() => GetPrivacyPolicyUseCase(
|
||||
i<PrivacySettingsRepositoryInterface>(),
|
||||
),
|
||||
|
||||
@@ -26,12 +26,12 @@ class StaffMainModule extends Module {
|
||||
@override
|
||||
void binds(Injector i) {
|
||||
// Register the StaffConnectorRepository from data_connect
|
||||
i.addSingleton<StaffConnectorRepository>(
|
||||
i.addLazySingleton<StaffConnectorRepository>(
|
||||
StaffConnectorRepositoryImpl.new,
|
||||
);
|
||||
|
||||
// Register the use case from data_connect
|
||||
i.addSingleton(
|
||||
i.addLazySingleton(
|
||||
() => GetProfileCompletionUseCase(
|
||||
repository: i.get<StaffConnectorRepository>(),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user