-
-
Notifications
You must be signed in to change notification settings - Fork 4
ViewModels or ObservableObjects
Marc Rousavy edited this page Aug 22, 2018
·
8 revisions
In Jellyfish one distinguishes between an observable object and a view model:
-
ObservableObject
: An object that implements theINotifyPropertyChanged
interface by notifying any subscribers upon property changes via theSet
method -
ViewModel
: The actual ViewModel in the MVVM Pattern. A ViewModel also inherits from ObservableObject, but provides additional functionality specifically for ViewModels
View Model:
class UserViewModel : ViewModel
{
private User _user;
public User User
{
get => _user;
set => Set(ref _user, value);
}
public void LoginAction()
{ ... }
}
Observable Objects:
class User : ObservableObject
{
private string _name;
public string Name
{
get => _name;
set => Set(ref _name, value);
}
private DateTime _birthday;
public DateTime Birthday
{
get => _birthday;
set => Set(ref _birthday, value);
}
}
See also: ViewModel π, Observable Object π