Astra Child

Bind

Estimated reading: 2 minutes 0 views

What is a Bind? 

A Bind is a runtime object that is responsible for storing and synchronizing the values of its connected Bindables. It acts as an intermediary between the Bindables, passing values between them based on their connection types.

How it works

A Bind is usually created by a Binder component at runtime, although it can also be created directly from code. It has a static class database of Binds that allows the developer to get a reference to any Bind in code via a BindId (Category Name pair).

When a Binder component is enabled, OnEnable it connects its Bindables to the Bind it is connected to. Bindables can also be added to a Bind directly from code, allowing for greater flexibility in how objects are connected.

Once connected, the Bind is responsible for synchronizing the values of its Bindables based on their connection types.

For example, if a Bindable is connected with a Bidirectional connection type that gets and sets the value, the Bind will get value from the Bindable, when its value changes, and send it to all other Bindables that use a Receiver or Bidirectional connection. This also means that when the value changes the Bind will set the value to the Bindable.

Not all Binds need to have a BindId, but it is needed for the disconnected approach where Bindables are not directly connected to each other but are connected to the same Bind using a shared identifier.

In summary, a Bind is a powerful tool for synchronizing values between objects at runtime, and is a key component of the Bindy system.

Share this Doc
CONTENTS
Scroll to Top