dphfox / Fusion

A modern reactive UI library, built specifically for Roblox and Luau.
https://elttob.uk/Fusion/
MIT License
530 stars 91 forks source link

Memoise special key generation functions #320

Closed dphfox closed 2 months ago

dphfox commented 2 months ago

OnEvent "Activated" should always return the same special key. Ditto for OnChange, Out, and all other special key generation functions.

This allows for easy passthrough with components:

print(props[OnEvent "Activated"]) -- valid

But disallows multiple of the same handler being added to instances:

scope:New "TextButton" {
    [OnEvent "Activated"] = ...,
    [OnEvent "Activated"] = ..., -- no longer valid
}

However, there's little evidence that multiple handlers are used in practice. Should the problem arise, we can investigate alternate API surfaces similar to #137.