These are chat archives for AvaloniaUI/Avalonia

5th
Jan 2015
José Manuel Nieto
@SuperJMN
Jan 05 2015 09:47
Good morning, people! writing from the office
I will try to make some progress with the property paths
I've never done such a similar thing, but maybe it's like a linked list
This message was deleted
This message was deleted
José Manuel Nieto
@SuperJMN
Jan 05 2015 09:53
if you have instance x
and you want to bind to "Prop1.Prop2.Prop3"
that is a path over x
how would you do it?
a change in Prop1 should also taken into account
I guess that it's necessary to update whenever Prop1, Prop2 or Prop3 change
it's kind of complex, because... how do you detect changes?
in all the members of the chain?
should the members be observable?
What happens if Prop1 is observable and Prop2, Prop3 aren't
what if Prop1 is a struct?
José Manuel Nieto
@SuperJMN
Jan 05 2015 09:58
argh
Steven Kirk
@grokys
Jan 05 2015 10:41
hi josé
i know that reactiveui supports things like vm.WhenAnyValue(x => x.Prop1.Prop2.Prop3)
it sets up a chain of objects to listen to
i'm not entirely sure where the code is
i have a feeling that GetExpressionChain here https://github.com/reactiveui/ReactiveUI/blob/master/ReactiveUI/ExpressionMixins.cs might be something to do with it
Steven Kirk
@grokys
Jan 05 2015 10:49
btw: i agree that the solution you and @glennblock came up with of using named lambdas for type converters would be a nice way of doing it
i personally would still like to see expressions in xaml, but i realise that would be difficult!
José Manuel Nieto
@SuperJMN
Jan 05 2015 10:52
hi @grokys! thanks for pointing out
the WhenAnyValue method could contain useful code
my case is slightly different. It's not strongly typed at all. The path comes from a string
"Phony.Johnny.Mahoney"
I'll dig into that code to see how it works
maybe I'll find a clue!
I'm afraid of possible castings to INotifyPropertyChanged
to know wheter something supports change notifications or not :worried:
Steven Kirk
@grokys
Jan 05 2015 10:59
yes, you will have to do that
every object in the chain that implements INPC will need a listener
Steven Kirk
@grokys
Jan 05 2015 11:51
also, you'll need to handle [indexers] and INotifyCollectionChanged
as i said a while ago - it's not so simple, which is why i was just using reactiveui
Glenn Block
@glennblock
Jan 05 2015 18:33
Yes you need to walk the graph, handle collections etc. Another thing is making sure there are no memory leaks as subscribing to events can prevent the sender from being fully released.
Glenn Block
@glennblock
Jan 05 2015 18:55
Actually it is the reverse…the subscriber is what is held alive if you are not careful.
Steven Kirk
@grokys
Jan 05 2015 19:18
In fact, would it need to use weak event subscriptions?
Glenn Block
@glennblock
Jan 05 2015 19:19
weak events would be best
weak delegates….
In Prism the EventAggregator used a Weak delegate for this reason
Steven Kirk
@grokys
Jan 05 2015 19:22
I seem to remember reactiveui does too
José Manuel Nieto
@SuperJMN
Jan 05 2015 20:15
reading!
I've seen weak events from here and there
but I've never used them
I imagine it's not very difficult :)
thanks for the link and the ideas!