I was writing an Obsidian extension and struggled with creating a virtual list.
I decided to finally use Elm and found FabienHenon/elm-infinite-list-view but it assumes I know the height of my items in advance. I don’t.
So I wrote my own virtual list which worked extremely well, especially considering the fact that this is my first experience writing Elm code.
I would like to share the list with others that have the same problem and would be very grateful if someone with experience could have a look and let me know if there is anything I could do to improve the code, the API design, the documentation. I’m very new to this. Please be kind .
Because it would break the plugin publishing flow I haven’t created a package yet. The virtual list is in its own documented module, though, and ready to be packaged and published.
(I know that the documentation should not be indented, but I can’t get elm-format to leave it alone.)
How do you deal with not knowing the height of the items in advance? Is it possible with your solution to have items of varying heights in the same virtual list?
The virtual list will measure the hight of these items when they first appear. By default the list will be shown once the initial items are measured. You can also show it while measurement takes place.
Ok I see. You require the caller to pass in the height function (Int -> item -> Int). Which is a perfectly good way to do it - push the responsiblity back onto the caller.