watch method

bool watch(
  1. BuildContext context,
  2. Entitlement entitlement
)

Implementation

bool watch(BuildContext context, Entitlement entitlement) {
  final Element element = context as Element;
  if (_watchers[element] == null) {
    late final StreamSubscription<void> subscription;
    subscription = entitlementChanges.listen((_) {
      if (element.mounted) {
        element.markNeedsBuild();
        return;
      }
      _watchers[element] = null;
      unawaited(subscription.cancel());
    });
    _watchers[element] = subscription;
  }
  return holds(entitlement);
}