-
Notifications
You must be signed in to change notification settings - Fork 432
[General] Ability to change service lifetime #2991
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
Conversation
To be clear:
In general, including for Blazor WebAssembly, it is recommended to use I have 3 comments about this PR:
|
I taught that when you have WebAssembly using scoped is useless, does not exists and only stops you from using the services in Singleton services. And it seems this is in the documentation as well. You always have the option to do your own service registering, but that will lead to people forgetting new services. Giving the option to use the default registration while still allowing to change the lifetime seems like a nice way for developers. Off-course this should NEVER be used when using this server side, because there you have a scope per request which makes far more sense. |
Yes and no :-)
So, the services injected using |
If they behave the same, then it helps to make them singleton in the first place. Because if you want to retrieve any service from a singleton service it has to be either a singleton as well or a transient service. If it is scoped, you're forced to create a "fake" scope from your singleton service, and then retrieve the service which acts like a singleton anyway (on webassembly). |
Now I understand. You want to retrieve a FluentUI service from a Singleton service. It's really a special case. And I don't think we need to manage it from the library. You can inject these services manually to use the Singleton without calling Or via a |
No I don't want that, did not have a use case for this yet. But I understand the question from #2691 and though I would fix some of the long standing issues. |
By adapting your PR to put this Flag in the LibraryConfiguration object, I think it would be better adapted. |
cc0e169
to
99677b0
Compare
Head branch was pushed to by a user without write access
Pull Request
📖 Description
There are situations where you might want to access the built-in services from a singleton service. This pull requests allows the developer to configure the lifetime if needed. Normal operation is not changed
🎫 Issues
👩💻 Reviewer Notes
Normal operation is not changed, only the ability to register the services as Singleton
📑 Test Plan
✅ Checklist
General
Component-specific
⏭ Next Steps