Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Allow Roact Bindings to skip property updates #375

Open
Pyseph opened this issue Jul 21, 2022 · 1 comment
Open

Allow Roact Bindings to skip property updates #375

Pyseph opened this issue Jul 21, 2022 · 1 comment

Comments

@Pyseph
Copy link

Pyseph commented Jul 21, 2022

Currently it's not possible to skip a binding property update as Roact does not check what the return is. This eliminates optimization possibilities when ex. sharing a Binding across 500 components, where not all components may need to update their properties depending on what the new data is.

An alternative solution would be to create a binding for each component, but this would increase memory and force further changing of code to make sure bindings are only created once for each unique component.

A proposition to this would be to allow Binding:map to return a unique value which lets Roact know that the property should not be updated, e.g:

Roact.createElement("Frame", {
    Size = props.Binding:map(function(Data)
        if not Data.Visible then
            return Roact.Constant.SkipBindingUpdate
        end
        return Data.Size
    end),
    Visible = props.Binding:map(function(Data)
        return Data.Visible
    end)
})

Of course this is not a final proposition nor am I aware of the design choices which Roact may want to adhere to, so I'm fine with any solutions so long it allows for skipping unnecessary property updates in performance-critical code.

@Pyseph
Copy link
Author

Pyseph commented Jul 21, 2022

I created a fork and introduced the proposed solution in the commit below:
Pyseph@53272ef

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant