-
-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Brainstorm improvements to SubModelSelectedItem #189
Comments
After I started using So I've been wondering why these aren't exposed. I don't doubt there can be really good reasons for that. I wonder whether a more generic mechanism can be made, that can be used to handle SelectedItem and SelectedItems if they turn out to be the only options, and also properties like IsSelected and events like Selected and Unselected from the sub view. I wonder whether other properties or events exists that will need to be handled in similar ways. Just loose thoughts, not opinions or propositions. The reason for bringing this up here, is that it may affect whether work is put into improving |
Just want to let you guys know that I won't have a chance to look at all the recent activity in the repo until this weekend at the earliest, potentially not before the next weekend. |
@cmeeren (edit: and @bender2k14), I have no issues that needs resolving, so please don't feel any pressure from me. Just throwing in my two cents worth of thoughts here, but I'll stay quiet for a while now I think. |
Ah, not exactly. It makes the recursion of |
Some quick thoughts:
While I'd ideally like it to be more safe, it must also be balanced against how simple the public API is, and how likely the API is to cause significant problems. I like the idea of not being able to create invalid bindings, but with a new binding that combines A possible solution is to extend the Another option is of course to just keep
I'll let you decide what's more or less difficult here. :) Note that, as a general policy, I'd rather not force a worse API on users (if it turns out to be worse) in order to make internals easier, unless it's a significant gain in the internals for a small loss in the public API. |
For the record, #174 (comment) is relevant here. The controls to be supported may influence the implementations. |
That's true. For the sake of simplicity though, I think is reasonable to only consider the current implementation for the purposes of this issue. |
This hasn't seen any activity for a while. Also, I still haven't received any complaints from users regarding the current |
I am in no rush to change the current implementation, and we can close this. I will comment here if I have any new thoughts. |
This is a spinoff of #188
Quoting #188 (comment)
So, what are its downsides?
The main two downsides I see are:
The first issue is that
subModelSelectedItem
refers to asubModelSeq
by name, which might not exist during initialization.Elmish.WPF/src/Elmish.WPF/ViewModel.fs
Line 394 in c9b6fb5
In the following example (from the
SubModelSelectedItem
sample), that name isEntities
.Elmish.WPF/src/Samples/SubModelSelectedItem/Program.fs
Lines 32 to 40 in c9b6fb5
The second issue is that
initializeBinding
takes a functiongetInitializedBindingByName
so that the initializedSubModelSeq
binding can be obtained when initializing theSubModelSelectedItem
binding.Elmish.WPF/src/Elmish.WPF/ViewModel.fs
Line 219 in c9b6fb5
Elmish.WPF/src/Elmish.WPF/ViewModel.fs
Lines 382 to 384 in c9b6fb5
My idea to address both of these downsides is to "combine" these bindings into one compound binding.
From the user's perspective, it would look something like
There very well might be some syntactic improvements possible there. The main thing that I am trying to suggest there is, compared to the current approach, that both the
SubModelSeq
binding and theSubModelSelectedItem
binding are defined by the user at the same time. This would roughly correspond to changing...Elmish.WPF/src/Elmish.WPF/Binding.fs
Lines 112 to 123 in c9b6fb5
...by replacing
SubModelSelectedItem
with something likeSubModelSeqAndSelectedItem
.To be clear, there is no corresponding change to
Elmish.WPF/src/Elmish.WPF/ViewModel.fs
Lines 89 to 101 in c9b6fb5
Instead,
initializeBinding
changes by returning a sequence of bindings instead of an optional binding (i.e. at most one binding). The sequence would contain exactly one binding in every case except forSubModelSeqAndSelectedItem
when it returns a sequence containing exactly two bindings.I think that this approach removes both of the major drawbacks with
SubModelSelectedItem
. If it seems like a good idea, then I could try to implement this approach (making various decisions along the way I as I see fit) as a proof of concept.Are there any other drawbacks that I missed?
Does anyone have any other ideas for improving
SubModelSelectedItem
?The text was updated successfully, but these errors were encountered: