refactor: change singleton registrations to lazy singleton for improved performance
This commit is contained in:
@@ -666,17 +666,17 @@ class StaffConnectorRepositoryImpl implements StaffConnectorRepository {
|
||||
class StaffMainModule extends Module {
|
||||
@override
|
||||
void binds(Injector i) {
|
||||
i.addSingleton<StaffConnectorRepository>(
|
||||
i.addLazySingleton<StaffConnectorRepository>(
|
||||
StaffConnectorRepositoryImpl.new,
|
||||
);
|
||||
|
||||
i.addSingleton(
|
||||
i.addLazySingleton(
|
||||
() => GetProfileCompletionUseCase(
|
||||
repository: i.get<StaffConnectorRepository>(),
|
||||
),
|
||||
);
|
||||
|
||||
i.addSingleton(
|
||||
i.addLazySingleton(
|
||||
() => StaffMainCubit(
|
||||
getProfileCompletionUsecase: i.get(),
|
||||
),
|
||||
@@ -772,7 +772,7 @@ StateError: Cannot emit new states after calling close
|
||||
|
||||
```dart
|
||||
// ✅ GOOD: Singleton registration
|
||||
i.addSingleton<ProfileCubit>(
|
||||
i.addLazySingleton<ProfileCubit>(
|
||||
() => ProfileCubit(useCase1, useCase2),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user