call method

  1. @override
T call([
  1. T? newValue,
  2. bool nulls = false
])
override

Sets the value of the signal.

Implementation

@override
T call([T? newValue, bool nulls = false]) {
  if (newValue != null || (null is T && nulls)) {
    if (latestValue != newValue) {
      latestValue = newValue as T;
      flags = 17 /* Mutable | Dirty */;
      if (subs case final Link link) {
        propagate(link);
        if (batchDepth == 0) flush();
      }
    }

    return latestValue;
  }

  /*----------------- getter 👇 ------------------------*/

  if ((flags & 16 /* Dirty */) != 0 && shouldUpdated()) {
    final subs = this.subs;
    if (subs != null) shallowPropagate(subs);
  }

  ReactiveNode? sub = activeSub;
  while (sub != null) {
    if ((sub.flags & 3 /* Mutable | Watching */) != 0) {
      link(this, sub, cycle);
      break;
    }

    sub = sub.subs?.sub;
  }

  return latestValue;
}