Skip to content

Explicit reuse of values in Lwd_seq.Reducer #39

@Julow

Description

@Julow

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions