Class BindableVariable<T>
Generic class which contains a member variable of type T and provides a binding API to data changes.
Implements
Inherited Members
Namespace: Unity.XR.CoreUtils.Bindings.Variables
Assembly: Unity.XR.CoreUtils.dll
Syntax
public class BindableVariable<T> : BindableVariableBase<T>, IReadOnlyBindableVariable<T> where T : IEquatable<T>
Type Parameters
| Name | Description |
|---|---|
| T | The type of the variable value. |
Remarks
T is IEquatable to avoid GC alloc that would occur with object.Equals in the base class.
Constructors
BindableVariable(T, bool, Func<T, T, bool>, bool)
Constructor for bindable variable of type T, which is a variable that notifies listeners when the internal value changes.
Declaration
public BindableVariable(T initialValue = default, bool checkEquality = true, Func<T, T, bool> equalityMethod = null, bool startInitialized = false)
Parameters
| Type | Name | Description |
|---|---|---|
| T | initialValue | Value of type |
| bool | checkEquality | Setting true checks whether to compare new value to old before triggering callback. Defaults to true. |
| Func<T, T, bool> | equalityMethod | Func used to provide custom equality checking behavior. Defaults to |
| bool | startInitialized | Setting false results in initial value setting will trigger registered callbacks, regardless of whether the value is the same as the initial one. Defaults to false. |
Methods
ValueEquals(T)
Evaluates equality with the internal value held by the bindable variable.
Declaration
public override bool ValueEquals(T other)
Parameters
| Type | Name | Description |
|---|---|---|
| T | other | Other value to compare equality against. |
Returns
| Type | Description |
|---|---|
| bool | True if both values are equal. |