Hello,
As the title says, I'd love to understand better what @Injectable actually do and when it is necessary.
From experimenting it seems to only be needed when the class (annotated with it) needs to have its dependencies injected. If the class does not need DI is it correct that @Injectable is not needed ?
I was a bit confused as I also thought that annotating a class with @Injectable was needed to have the class itself be injected elsewhere but from experimenting it does not seems right.
I am also confused about injection scopes as they are demonstrated here https://docs.nestjs.com/fundamentals/injection-scopes#usage. AFAIK a custom provider has noting to do with the @Injectable decoration, it just means that the consumer of that provider might want to opt out of the classic DI (so what determines if a provider is "custom" or not, lies on the consumer side). Thus I'm not sure to understand how the 2 examples are linked. When I want to adjust my injection scope do I need to configure this on the provided class itself (i.e. the service) using the @Injectable decorator ? Or do I need to configure this at the consumer level using the more verbose approach for custom providers ?
That's pretty much it, thanks a lot for the help 🙏
Nest is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).