Performance: Optional providers
MEDIUM IMPACT
This affects the application startup time and memory usage by controlling whether certain services are instantiated or skipped.
constructor(@Optional() private readonly optionalService?: OptionalService) {}constructor(private readonly optionalService: OptionalService) {}| Pattern | Service Instantiation | Startup Delay | Memory Usage | Verdict |
|---|---|---|---|---|
| Mandatory provider injection | Always instantiated | Increases delay | Higher memory use | [X] Bad |
| Optional provider injection | Instantiated only if provided | Minimal delay | Lower memory use | [OK] Good |