You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the common case we want to support and which allows the best experience.
We generate proxies that allows 2-way bindings to each (sub) properties, but which also implements IFeed<TRecord> .
The issue with all those different cases is that it make the usage in application way too difficult as depending of the kind of T you cannot use it the same way:
FeedView
direct binding
primitive
NO
YES
record
YES
YES
class
YES
NO
And even for record, as we are using proxies instead of concrete types, if we want to set an instance of the record from the view (instead of editing it property per property, eg. for selection) we have to data-bind to a magic Value property.
Proposed solution
We should instead make sure that no matter the kind of T we should be able to use it in direct binding and FeedView. This would be possible by changing the generated code to always generate a BindableXXX (or a generic Bindable<T>) no matter the kind of the value, then allow implicit conversion to T:
Uno's binding engine supports the TypeConverter, so could dynamically convert to T when the desired type is not a ISignal<IMessage> (the type of the Source DP of the FeedView)
Windows we could take advantage of the support ICustomPropertyProvider to support a fake MyProperty_Feed property that would be implicitly requested by the FeedView. It would then return either the T or the BindableT for the MyProperty property to allow 2-way direct binding.
Cons:
The FeedView would have specific support for the generated code.
Generated code would be more complex.
Why not make a distinction between IFeed and IState, and generate only IFeed for IFeed properties (usable with FeedView) and generate proxies for IState (usable with direct binding)?
It has been determined that it's common to mix a FeedView with a direct binding (e.g. the title of the page).
Why not always generate both T MyProperty and IFeed<T> MyProperty_Feed ?
This would make the code less readable when using CSharpMarkup
When using 2-way direct binding user would have to use the MyProperty_Feed property for changes to be reflected in the model
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
When we declare a
Feed<T>
in a model, depending of the kind ofT
the generated code won't be the same:When
T
is a primitive (ValueType
orstring
)We assumed that the typical usage of such feed would be for direct 2-way bindings like for a settings page, so we only generate a plain property.
When
T
is arecord
This is the common case we want to support and which allows the best experience.
We generate proxies that allows 2-way bindings to each (sub) properties, but which also implements
IFeed<TRecord>
.When
T
is aclass
As there is no way to clone the T when a sub property is changed, we only expose it as a
IFeed<TClass>
Usage in view
The issue with all those different cases is that it make the usage in application way too difficult as depending of the kind of
T
you cannot use it the same way:FeedView
record
class
And even for
record
, as we are using proxies instead of concrete types, if we want to set an instance of the record from the view (instead of editing it property per property, eg. for selection) we have to data-bind to a magicValue
property.Proposed solution
We should instead make sure that no matter the kind of
T
we should be able to use it in direct binding andFeedView
. This would be possible by changing the generated code to always generate aBindableXXX
(or a genericBindable<T>
) no matter the kind of the value, then allow implicit conversion toT
:TypeConverter
, so could dynamically convert toT
when the desired type is not aISignal<IMessage>
(the type of theSource
DP of theFeedView
)ICustomPropertyProvider
to support a fakeMyProperty_Feed
property that would be implicitly requested by theFeedView
. It would then return either theT
or theBindableT
for theMyProperty
property to allow 2-way direct binding.Cons:
FeedView
would have specific support for the generated code.Why not make a distinction between
IFeed
andIState
, and generate onlyIFeed
forIFeed
properties (usable withFeedView
) and generate proxies forIState
(usable with direct binding)?It has been determined that it's common to mix a
FeedView
with a direct binding (e.g. the title of the page).Why not always generate both
T MyProperty
andIFeed<T> MyProperty_Feed
?MyProperty_Feed
property for changes to be reflected in the modelIs
{x:Bind}
will still be supported?TBD
Beta Was this translation helpful? Give feedback.
All reactions