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 { class StaffMainModule extends Module {
@override @override
void binds(Injector i) { void binds(Injector i) {
i.addSingleton<StaffConnectorRepository>( i.addLazySingleton<StaffConnectorRepository>(
StaffConnectorRepositoryImpl.new, StaffConnectorRepositoryImpl.new,
); );
i.addSingleton( i.addLazySingleton(
() => GetProfileCompletionUseCase( () => GetProfileCompletionUseCase(
repository: i.get<StaffConnectorRepository>(), repository: i.get<StaffConnectorRepository>(),
), ),
); );
i.addSingleton( i.addLazySingleton(
() => StaffMainCubit( () => StaffMainCubit(
getProfileCompletionUsecase: i.get(), getProfileCompletionUsecase: i.get(),
), ),
@@ -772,7 +772,7 @@ StateError: Cannot emit new states after calling close
```dart ```dart
// ✅ GOOD: Singleton registration // ✅ GOOD: Singleton registration
i.addSingleton<ProfileCubit>( i.addLazySingleton<ProfileCubit>(
() => ProfileCubit(useCase1, useCase2), () => ProfileCubit(useCase1, useCase2),
); );

View File

@@ -2,6 +2,14 @@
<!-- Provide a clear and concise description of your changes --> <!-- 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 ## ✅ Testing
<!-- Describe how you tested these changes --> <!-- Describe how you tested these changes -->
@@ -93,7 +92,6 @@ Related to #
- [ ] Code quality and readability - [ ] Code quality and readability
- [ ] Design patterns follow project conventions - [ ] Design patterns follow project conventions
- [ ] Test coverage is adequate
- [ ] Performance implications reviewed - [ ] Performance implications reviewed
- [ ] Security concerns addressed - [ ] Security concerns addressed
- [ ] Documentation is complete - [ ] Documentation is complete