overrideWith method

Computed<T> overrideWith(
  1. T val
)

Override the current signal with a new value as if it was created with it

This does not trigger any updates

var counter = computed(() => 0);

// Override the signal with a new value
counter = counter.overrideWith(1);

Implementation

Computed<T> overrideWith(T val) {
  _fn = () => val;
  _flags = _OUTDATED;
  // _version = 0;
  _initialValue = val;
  _previousValue = null;
  return this;
}