After answering this question about whether the ViewModel is still applicable in MVC Core, I now find myself with a similar question in Blazor.
I'm starting to build my first complex Blazor page with a lot of state to manage. Elements of the page will show/hide and update depending on data entered on other parts of the page.
I've worked with React and Redux in the past and found great value in having a single location for all the state, especially for unit testing purposes.
Accordingly, my plan is to have a view-model that contains not only the data I'm going to persist to the database, but also potentially flags such as ShowSalesOrdersPanel
that will then be used in if
statements in the razor view.
My question is, should this view-model be a separate class, or is the @functions
section of the Blazor razor file effectively the view-model? Should I just use that instead?