unwatchSignal<T> function

void unwatchSignal<T>(
  1. BuildContext context,
  2. ReadonlySignal<T> signal
)

Remove all subscribers for a given signal for watchers

Implementation

void unwatchSignal<T>(BuildContext context, ReadonlySignal<T> signal) {
  final ctx = context;
  if (ctx.widget is Watch) return;
  if (ctx is StatefulElement) {
    final state = ctx.state;
    if (state is SignalsMixin) {
      return state.unwatchSignal(signal);
    }
  }
  final key = ctx.hashCode;
  _elementRefs.remove(key)?.unwatch(signal);
}