-
Notifications
You must be signed in to change notification settings - Fork 24
Description
The reducer seems to reuse old values, perhaps using physical equality on the elements of the sequence ?
It could be useful to pass a custom equality function and to define some guarantees about which values are reused.
I don't know which guarantees would be useful but I think it should be possible to avoid the lwd_to_remove marking step in tyxml-lwd's DOM update.
This trick cannot be used in a library where it's not possible to store new state on elements.
Reusing old values in a smart way should be able to avoid false-positives when listing dropped elements.
An element that moves would be removed then added again but this could be optimised an other way.
I noticed that in the code below, if I swap Lwd_seq.bind with Lwd_seq.lift, the whole sequence become dropped on every updates.
This might be because physical equality is lost when it wraps every elements of the sequence into a freshly allocated Lwd_seq.element. In the bind case, the sequence nodes are allocated once and shared (allocated outside of the document).
let$ childs = Lwd_seq.bind childs Fun.id in
let dropped, r = R.update_and_get_dropped !reducer childs in