get method

T get()

Returns the current value and links this node to the active subscriber.

When the node is dirty, pendingValue is committed before the read. After dispose, this returns pendingValue without tracking.

Example:

final node = SignalNode<int>(0);
Effect(() => node.get());

Implementation

T get() {
  if (!isDisposed) {
    assert(() {
      JoltDevTools.get(this);
      return true;
    }());
    if (flags & (ReactiveFlags.dirty) != 0) {
      if (update()) {
        if (subs != null) {
          shallowPropagate(subs!);
        }
      }
    }
    final sub = activeSub;
    if (sub != null) {
      link(this, sub, cycle);
    }

    return value as T;
  }
  return pendingValue as T;
}