centau / vide

A reactive Luau library for creating UI.
https://centau.github.io/vide/
MIT License
95 stars 16 forks source link

Allow nesting functions for updating children #40

Open alicesaidhi opened 2 months ago

alicesaidhi commented 2 months ago

Currently, it's not allowed to nest functions when updating children. Following code would error:

create "Frame" {
    indexes(t, function(name)
        return show(s, function()
            return create "Frame" {
                Name = name
            }
        end)
    end)
}

We can allow this behavior though through adding a single case to the update_children_effect function

elseif type(child) == "function" then
            process_child(child())

which would make the first example valid.

There is some value in allowing this behavior, as we would now be able to infinitely nest indexes, show, etc which may be more intuitive in roblox-ts. I believe @littensy also wanted this, considering that many of the control flow functions in vide are tsx elements there. Being able to treat them as regular components would be really nice for UX.