Make Components.list utility function use `Collection` instead of `List`
sisby-folk opened this issue · 1 comments
Hey hi there! Quick tiny thing - The list()
function could be a little easier to work with if it only required a Collection
rather than a List
. The implementation only iterates through them, so it shouldn't mind it being any kind of collection
owo-lib/src/main/java/io/wispforest/owo/ui/component/Components.java
Lines 134 to 136 in dd38739
Stuff like Map.values()
returns collections but not lists, and It'd save a bit of extra constructing.
This function requires a List
precisely because it makes an ordered list of components. Thus, it's only sensible to also require an ordered collection of items (which we then call a list) as input.
I believe this also encourages actually sorting the incoming data by some meaningful characteristic, which leads to much improved UX - having the same list of items be potentially in a different order every time I see it is not a great user experience.
While I can appreciate there may be cases where one has a collection with deterministic iteration order (like the values of a linked map) that is not a list, I don't think that warrants weakening this function's contract
Cheers