refactor: change singleton registrations to lazy singleton for improved performance

This commit is contained in:
Achintha Isuru
2026-03-07 01:00:59 -05:00
parent 16065bc824
commit e2f37dbe66
2 changed files with 12 additions and 14 deletions

View File

@@ -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),
);

View File

@@ -2,6 +2,14 @@
<!-- Provide a clear and concise description of your changes -->
---
## 🔗 Related Issues
<!-- Link any related issues using #issue_number -->
Closes #
Related to #
---
@@ -33,15 +41,6 @@
---
## 🔗 Related Issues
<!-- Link any related issues using #issue_number -->
Closes #
Related to #
---
## ✅ Testing
<!-- Describe how you tested these changes -->
@@ -93,7 +92,6 @@ Related to #
- [ ] Code quality and readability
- [ ] Design patterns follow project conventions
- [ ] Test coverage is adequate
- [ ] Performance implications reviewed
- [ ] Security concerns addressed
- [ ] Documentation is complete