get method

T get()

Gets the current value of the signal.

If the signal is dirty, updates it first. Automatically establishes a dependency relationship with the active subscriber if one exists.

Returns the current committed value.

Implementation

@pragma('vm:align-loops')
T get() {
  if ((flags & ReactiveFlags.dirty) != ReactiveFlags.none) {
    if (didUpdate()) {
      final subs = this.subs;
      if (subs != null) {
        shallowPropagate(subs);
      }
    }
  }
  ReactiveNode? sub = activeSub;
  while (sub != null) {
    if ((sub.flags &
            3 /*(ReactiveFlags.mutable | ReactiveFlags.watching)*/) !=
        ReactiveFlags.none) {
      link(this, sub, cycle);
      break;
    }
    sub = sub.subs?.sub;
  }
  return currentValue;
}