Clean Architecture Domain Data Bindings #15662
-
I am rebuilding my app using clean architecture with Avalonia for cross-platform support. I'm trying to follow the SOLID principles, but I've encountered some issues. The UI doesn't update after editing entities' properties like Name or Email; it only reflects changes when data is populated or when items are added or removed from the list, but the edited properties still same. I am trying to bind domain entities/models from the application layer without wrappers or custom view model per entity, in theory it should work, I am getting the output console messages correctly and I don't see the problem, I didn't use INotifyPropertyChanged or ReactiveObject in Domain since I want to keep it clean and independent from UI components and External libraries. Domain Layer
and Injecting this from presentation layer (AvaloniaUI) into the Presentation Layer
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Avalonia requires INotifyPropertyChanged, not that signal stuff. Check Avalonia.Samples MVVM samples. |
Beta Was this translation helpful? Give feedback.
-
In-memory domains with their own synchronization are hard to do correctly and yours ends up not being MVVM at all. If you're binding UI inputs to domain objects (either directly or using instant synchronization), you are necessarily putting your domain objects into an invalid state. This isn't acceptable to me. The ViewModel exists as a temporary, editable copy of some domain state, valid or not. So you need some way to suspend synchronization until validation can be performed on the entire object. Avalonia can bind to observables, so I would probably try that instead of this custom implementation + adapter. You can't raise INPC for a different object instance, AFAIK, but I could be wrong there. |
Beta Was this translation helpful? Give feedback.
-
I just found that using
|
Beta Was this translation helpful? Give feedback.
I just found that using
System.ComponentModel
andNotifyPropertyChanged
in Domain isn't a UI code so it doesn't violate the concern of separation principles, I just did this and it's working