[Feature Request] Scoped Factories
JCombee opened this issue · 1 comments
JCombee commented
For a usecase I would like to put the express instance in a container.
I wan't to be able to register this as a singleton so I can just get the instance everywhere in the application.
I think it would be a good addition to be able to define the scope for all types of tokens when registering.
zheksoon commented
Hi! Thanks for the request :)
A scope for a factory function means it's cached somewhere, which is not the case for current implementation. I think you can do workaround by creating a class that returns the express instance from its constructor, then it will be cached in the specified scope as usual.
If you have any specific examples you can express with code, will be glad to see it! :)