-
Hi, I'm looking for advice on how to make a model that works with FuncUI, for what's probably an unusual situation. I'm trying to show a list of millions of items, so I've got a ListBox with a VirtualizingStackPanel mapping an ImmutableList of the items. As I want to be able to attach extra info to some of the items in the list, without replacing the entire collection, I have an extra Map of item IDs (ints) to info. This map is in the model, and can be replaced whenever a change is made to this info. (The big collection and the notes to associate with the items are in different stores, which is another reason for this separation). I've made a cut-down Elmish example app of this (as a script or as an app)
I've put debugging output in the app which shows
If you enter text in the Notes field for Item 0 in the list, the Augmentations are updated and the separate Item0-specific panel also updates. But if you select item 1, scroll down the list and then back to the top, the notes for Item 0 get reset. The debugging output shows that the list item template was invoked with Augmentations version 0 rather than the most recent version when the template was re-created.
specifically the lines
This suggests to me that:
(Less importantly to me, if you enter text in the right-hand panel, the messages are sent to update notes for Item0, the list template is reconstructed, but the template is not invoked so the list does not update) So what I'm wondering is:
Any help or suggestions would be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
My attempt here was to use type MyDataTemplateView<'data, 'childData, 'view when 'view :> IView>(func) =
inherit DataTemplateView<'data, 'childData, 'view>(func, ValueNone, ValueNone, true)
override this.Equals(other) =
System.Object.ReferenceEquals(this, other)
override this.GetHashCode() =
func.GetType().GetHashCode()
static member create<'data, 'view> func =
new MyDataTemplateView<'data, _, 'view>(func) |
Beta Was this translation helpful? Give feedback.
-
Hi @marklam I'm taking a look later today. |
Beta Was this translation helpful? Give feedback.
I was looking at it and the item template has no reason to ever re-render.
The funny thing is that there is no way to fix this using elmish, without re-rendering your list.
You can easily fix this by using a component - but I'd strongly recommend to rewrite this using just components.