magicControllerEnricher function

String? magicControllerEnricher(
  1. Element element,
  2. RefRegistry refs
)

Enricher: emits magicControllerState: <ControllerClass>.<rxStatus> for the first MagicStateMixin-bearing controller registered via Magic.put.

Element-independent (the controller is a global singleton in the Magic registry), but kept as a per-element enricher so the YAML emitter consistently surfaces controller state next to each ref.

Returns null when no MagicStateMixin controller is registered.

Implementation

String? magicControllerEnricher(Element element, RefRegistry refs) {
  for (final Object controller in Magic.controllers) {
    if (controller is! MagicController) continue;
    final String? status = _readRxStatusName(controller);
    if (status == null) continue;
    final String className = controller.runtimeType.toString();
    return 'magicControllerState: $className.$status';
  }
  return null;
}