dphfox / Fusion

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

Add a conditional state object #378

Open dphfox opened 2 months ago

dphfox commented 2 months ago

Partial alternative to #377.

A more specific state object may be introduced for simple conditions:

local animShow = scope:If(show, 0.0, 1.0)

This would allow lazy evaluation of arguments.

znotfireman commented 2 months ago

My I recommend the name Switch or Toggle to match other libraries (e.g. Vide has the switch utility)

dphfox commented 1 month ago

We generally look to align with Luau, not outside libraries.

As a case study of why we don't do this, we originally aligned Value's naming with React - "State" - and it brought no material benefit. Instead, it just confused everyone, even though ostensibly React was serving UI developers all the same.

So we name things based on Luau as a general universal baseline, rather than imposing knowledge requirements on our users to understand what names mean.

In this case, both "Switch" and "Toggle" sound more like actions or stateful objects. Instead, this object represents a control flow expression. So the name instead tries to mirror Luau's if expression.