overrideWith method

  1. @Deprecated('Wrap signals/computeds in Ref from lite_ref and use Ref.overrideWith instead. ' 'This method will be removed in a future major release.')
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

@Deprecated(
  'Wrap signals/computeds in Ref from lite_ref and use Ref.overrideWith instead. '
  'This method will be removed in a future major release.',
)
Computed<T> overrideWith(T val) {
  fn = () => val;
  flags = OUTDATED;
  // _version = 0;
  afterCreate(val);
  return this;
}