AymenDaoudi
AymenDaoudi

Reputation: 8309

What does "Stateful" means in Stateful ViewModel in MVVM

I was reading about some XAML patterns, and there was the Stateful ViewModel, according to what I read it has nothing different than what we as just the "ViewModel".

Here's a description for example :

Stateful View Model:

To create isolation between business logic and presentation, data should be removed from the view. The stateful view model pattern moves data into the view model using XAML data binding. This allows the view model to be tested without constructing a view, and it allows the view to change with minimal impact on the business logic.

What is so special about it to be called Stateful ViewModel ? why isn't just called ViewModel

Link : http://www.xamlpatterns.com/stateful-view-model

Upvotes: 0

Views: 720

Answers (1)

VidasV
VidasV

Reputation: 4895

In my opinion stateful VM represents "stateful" object that can change during view lifetime and even outlive it for the next instance of view to use the very same VM. Also, it could have various view-switches, cases depending on present data facts and etc. While the basic VM would repesent a data carier for short time, like displaying a list of DB results or serving as a form field container, bound to the view. So whenever the operation with a view is finished the viewmodel is no longer needed.

Now regarding the definition you posted, it does say the exact same to stateful and stateless.

Upvotes: 2

Related Questions