roact icon indicating copy to clipboard operation
roact copied to clipboard

Add "ensureBinding" Function To Binding API

Open The-Big-Bird opened this issue 4 years ago • 0 comments

Problem

Currently, when accepting values & bindings interchangeably under the same prop; we're forced to write two different types of logic for the same prop and it's near-impossible to join several of these props together externally.

image (Example of hacky solution to allow for the "map" method to be used regardless of prop type.)

Solution

Add a function to the binding API to ensure a prop is given the same behavior and methods as a binding if it isn't a binding already.

Benefits

This would allow for both values and bindings to be passed under the same prop without having to code in hacky binding type checks with separate behavior. This would also allow for these aforementioned props to be joined together and behave as expected regardless of which of them are passed in as bindings.

Non-binding prop values that are assigned binding behavior under this function could have their internal subscription behavior removed as to not add extra unnecessary performance hits.

The-Big-Bird avatar Jun 14 '21 12:06 The-Big-Bird