Performance: Custom providers
MEDIUM IMPACT
Custom providers affect the dependency injection initialization time and memory usage during app startup.
providers: [{ provide: 'MY_SERVICE', useFactory: () => new Service(), inject: [] }]providers: [{ provide: 'MY_SERVICE', useFactory: () => { heavyComputation(); return new Service(); } }]| Pattern | Initialization Time | Memory Usage | Blocking Behavior | Verdict |
|---|---|---|---|---|
| Heavy synchronous factory | High | High | Blocks startup | [X] Bad |
| Lightweight factory with no heavy work | Low | Low | Non-blocking | [OK] Good |