Skip to content

Add list support #17

@mindplay-dk

Description

@mindplay-dk

I tried to prototype an implementation of map here - and it "works", but not the way we need.

https://codesandbox.io/s/try-haptic-0-10-e9le1?file=/src/map.js

The problem here is the return newNodes statement at the end. The work is already done, so I don't need the framework to do anything here... But if I don't return anything, it wipes out the DOM - whereas, if I do return the list of nodes, it replaces the entire range of nodes, undoing the work that diff just did, making the whole thing pointless.

In my own toy Sinuous clone, this approach worked well, because reactions don't return anything that gets automatically applied to the DOM - only creation is handled at the framework level, updates are performed by the reactive listener on the DOM directly.

I'm not sure how to make this fit into Haptic.

If we have to return newNodes and let Haptic do the work, then it would need to be able to diff the result - integrating diff at that level. But that would have performance implications, I think? We would be diffing also in cases where the intent is to actually just replace, which would work, but almost definitely isn't acceptable for performance (and bundle size) reasons, right?

Any idea how this would fit with Haptic?

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