DI Scoping in Maui - Multi User Application #16295
Unanswered
shadowfoxish
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Consider a functional approach your UI is produced using { user } You can have multiple user logged in, but to switch between user you would recreate the UI, leaving no chance for 'lingering UI' as you mentioned that would potentially be a problem. You can achieve the result using object oriented programming to create objects that represent the UI you are building, and functional oriented programming to avoid shared mutability, don't worry about overhead because it's not backend it's front end |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
tl;dr : How can I insert a "Scope" that the application can manage into the default DI container from which all subsequent GetService requests will come through?
I have an application that is used by warehouse folks where multiple people may log in/out of the same instance of the app without closing it. I have written stuff to update services when this happens, but my main problem is just that some of the view models and pages (which are all registered as Transient) are lingering between different logins. I don't know why these transients are being re-used but they are and whatever, it's generally fine as long as the user doesn't change.
I'd like to use DI scopes for this so that each time a user logs out a new DI scope is created and essentially all previous instances of the services go away and the new user gets new instances.
Flow: App Builder -> Create Scope -> Show Login Page -> User session -> User logs out -> Old scope closed, create new scope -> Show Login Page
I feel like this should be very possible, but I'm not sure how to kind of get in the middle of the ServiceProvider and add a custom implementation that allows me to tell it when to start a new scope.
Beta Was this translation helpful? Give feedback.
All reactions