tsyringe icon indicating copy to clipboard operation
tsyringe copied to clipboard

Default values for @inject()

Open SirBernardPhilip opened this issue 3 years ago • 4 comments

Even though there is already the registry, where we can set the providers for the injections. It was discussed in a not so recent issue that the possibility of having default or optional dependencies would be interesting. Since I have not seen it being implemented I came up with this simple first implementation. It does more or less the same that @registry() does but within the @inject() decorator, which will allow for simpler code I believe.

SirBernardPhilip avatar Apr 26 '21 15:04 SirBernardPhilip

CLA assistant check
All CLA requirements met.

ghost avatar Apr 26 '21 15:04 ghost

Interesting. I think this is workable. Could you update the documentation?

MeltingMosaic avatar Feb 25 '22 22:02 MeltingMosaic

Interesting. I think this is workable. Could you update the documentation?

Great! I have added an extra sentence to the inject() section. If you think it needs further explanation or even an example let me know.

SirBernardPhilip avatar Feb 27 '22 19:02 SirBernardPhilip

This would be awesome, any news on this?

RaulPROP avatar Sep 15 '22 11:09 RaulPROP