Class Bindable<T>
- Namespace
- Bindables
- Assembly
- Bindables.dll
A container that holds a value and notifies observers when that value changes.
[Serializable]
public class Bindable<T> : IBindWritable<T>, IBindable<T>, IBindable, IBindWritable
Type Parameters
TThe type of the value stored in the bindable.
- Inheritance
-
Bindable<T>
- Implements
-
IBindable<T>
- Derived
- Inherited Members
- Extension Methods
Constructors
Bindable()
public Bindable()
Bindable(T)
Initializes a new bindable with the specified initial value.
public Bindable(T value)
Parameters
valueTThe initial value for the bindable.
Fields
_value
[SerializeField]
protected T _value
Field Value
- T
Properties
Value
Gets the current value of the bindable.
public T Value { get; set; }
Property Value
- T
Methods
NotifyChanged()
Manually triggers change notifications for observers. Use this when the bindable's internal state changes without setting the Value property.
public void NotifyChanged()
SetValueWithoutNotify(T)
Sets the value without triggering change notifications. Useful for initialization or when you want to batch multiple changes.
public void SetValueWithoutNotify(T value)
Parameters
valueTThe new value to set.
ToString()
public override string ToString()
Returns
Events
OnChange
Event triggered when the bindable value changes.
public event Action OnChange
Event Type
OnChangeWithValue
Event triggered when the bindable value changes, providing the new value.
public event Action<T> OnChangeWithValue
Event Type
- Action<T>
Operators
implicit operator T(Bindable<T>)
public static implicit operator T(Bindable<T> prop)
Parameters
propBindable<T>
Returns
- T