MVVM Pattern Suggestion #608
Unanswered
mthrift2100
asked this question in
Q&A
Replies: 0 comments
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.
-
Current State
We support various AspNetCore web applications with a Blazor WebAssembly front end for internal business use. That front-end is supported by the MVVM pattern using the MVVM ToolKit.
As is typical with Blazor WebAssembly, our ViewModels are represented by interfaces that are injected into the razor component. We utilize the OnInitialized override to hook up our ViewModel events.
The Question
What are some solutions for creating a reusable way to have a ViewModel solicit feedback from the UI while it is in the middle of executing a function? The solution should not require the ViewModel to have knowledge of the UI stack. Our ViewModel interfaces and their implementations are in their own class library project and have no dependency on the UI or Blazor.
I want to avoid each ViewModel having to declare a custom event or custom Task<Func>.
For example, if after clicking a Save Button, the ViewModel needs to consume credentials that the user must supply, or based on some initial business logic, the ViewModel wants to make the user aware of some condition and solicit feedback as to whether it should continue with the work.
Should these concerns even be part of the ViewModel?
Handling user interaction during the middle of a ViewModel Task is one of the gaps that we have never had a satisfactory solution for.
Any thoughts?
Beta Was this translation helpful? Give feedback.
All reactions