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

Allow Roact Bindings to skip property updates #375

@Pyseph

Description

@Pyseph

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions