Class NodeController<T>
- Namespace
- WitShells.DesignPatterns.Core
Abstract reactive node wrapper that combines the Builder, Observer,
and Bindable patterns into a single unit.
Each node wraps a value of type T inside a Bindable<T>
so that listeners are automatically notified on change.
When the node is no longer needed, call Dispose() to broadcast its removal
via OnRemoved.
public abstract class NodeController<T> : Builder<T>, IBuilder<T>, IEquatable<T>
Type Parameters
TThe data type wrapped by this node.
- Inheritance
-
Builder<T>NodeController<T>
- Implements
-
IBuilder<T>IEquatable<T>
- Inherited Members
Constructors
NodeController(T)
Initialises the node with an initial value.
public NodeController(T node)
Parameters
nodeTThe initial data value for this node.
Properties
CurrentNode
The underlying reactive value wrapped by this node.
public Bindable<T> CurrentNode { get; }
Property Value
- Bindable<T>
OnRemoved
Fires when this node is disposed, passing the final node value to all listeners.
public ObserverPattern<T> OnRemoved { get; }
Property Value
Methods
Build()
Returns the current node value (satisfies the Builder<T> contract).
public override T Build()
Returns
- T
Dispose()
Signals removal of this node by notifying OnRemoved observers with the current node value.
public void Dispose()
Equals(T)
Indicates whether the current object is equal to another object of the same type.
public virtual bool Equals(T other)
Parameters
otherTAn object to compare with this object.
Returns
~NodeController()
protected ~NodeController()
ForceTrigger()
Forces OnValueChanged to fire with the current value even if the value has not changed. Useful for initialisation-time binding.
public virtual void ForceTrigger()
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
UpdateNode(T)
Updates the node's value. Triggers OnValueChanged if the value changed.
public virtual void UpdateNode(T newValue)
Parameters
newValueTThe new value to assign.