Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Scoped Factories #10

Open
JCombee opened this issue Aug 17, 2024 · 1 comment
Open

[Feature Request] Scoped Factories #10

JCombee opened this issue Aug 17, 2024 · 1 comment

Comments

@JCombee
Copy link

JCombee commented Aug 17, 2024

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
Copy link
Owner

zheksoon commented Aug 18, 2024

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! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants