ObservableProperty: Additional source generated method to allow binding with IObservables (inspired by Flux/Redux) #792
Unanswered
aseminjakiw
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
-
TLDR;
I have this view model:
And I would like to have a source generator to generate a method like this, additionaly to the current source generators:
This is essentially the same as the generated property setter but without the
On***Changeing
andOn***Changed
calls.Background
For some time I want to use a Flux/Redux like approach in an XAML environment and MVVM'ish approach. For this I need to consume an
IObsevable<T>
. The challenge is that you need a way to tell the UI that a value changed but at the same time allow for two-way binding scenarios (e.g. SelectedItem in a collection). The generatedOn***Changed
methods are great to collect the changes coming from the UI and initiate some action. But if we use the same property setter for changes coming from the internal application state you are at risk to produce an infinity loop.So I would like to have a "three-way property" with
On***Changed
and (optionally) raisingINotifyPropertyChanged
INotifyPropertyChanged
to inform UI about changesWith this in place you could write your view model code like this:
Questions
Beta Was this translation helpful? Give feedback.
All reactions