watchSignal<T> function
Watch a signal value and rebuild the context of the Element if mounted and mark it as dirty
Implementation
T watchSignal<T>(
BuildContext context,
ReadonlySignal<T> signal, {
String? debugLabel,
}) {
if (context is Watch) return signal.value;
if (context is Element) {
final key = context.hashCode;
if (_elementRefs[key] == null) {
final watcher = ElementWatcher(key, WeakReference(context));
_elementRefs[key] = watcher;
_init();
}
_elementRefs[key]?.watch(signal);
}
// Grab the current value without subscribing
return signal.peek();
}