-
-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dissolve state objects that don't deal with state #301
Comments
In combination with #300, this also means that observers of constant values would be reduced to a table of either no-ops or functions that execute whatever callback is given to them. |
There's a really clever way to do this under both eager and lazy execution (#144) - at the very start of the This still obeys the |
It's probably important to clarify that this optimisation only applies to state objects that don't specify any additional methods. For example, while |
I'm probably going to mark this issue as blocked again for the time being. Considerations around nested state objects nullify a bit of the benefit of a change like this, and Fusion isn't really ready to tackle unknown nesting levels quite yet. Luau's type checking probably wouldn't work well either. So I'll keep this around as a longterm goal instead. |
Right now, we encourage users to create
Computed
objects whenever they're dealing with possible state objects, e.g.However, in these scenarios, you can often end up with computations that deal entirely with constant values, for which a state object is completely redundant.
In these cases, I propose that state object constructors should be able to return constant values if they can prove that they will evaluate to a constant value. This is definitely a breaking change, but I feel that our ability to interchangeably handle constants and state objects should make it trivial to work with.
The above example becomes:
The allocation of the object can be completely avoided, lowering memory usage. State object constructors are re-conceptualised as suggestions that something may change, which Fusion can optimise away.
The text was updated successfully, but these errors were encountered: