subscribe method

EffectCleanup subscribe(
  1. void fn(
    1. T value
    )
)

Subscribe to value changes

Implementation

EffectCleanup subscribe(void Function(T value) fn) {
  return effect(() {
    final value = this.value;

    final prevContext = _evalContext;
    _evalContext = null;
    try {
      fn(value);
    } finally {
      _evalContext = prevContext;
    }
  });
}