onUIEvent method

Future<void> onUIEvent({
  1. String? elementId,
  2. String? widgetPath,
  3. String? action,
  4. Map<String, dynamic>? metadata,
})

Process UI event and execute rules

Implementation

Future<void> onUIEvent({
  String? elementId,
  String? widgetPath,
  String? action,
  Map<String, dynamic>? metadata,
}) async {
  if (!_engine.isActive) return;

  try {
    final eventContext = EventContext(
      elementId: elementId,
      widgetPath: widgetPath,
      action: action,
      metadata: metadata,
    );

    final rulesContext = UIRulesContext(
      event: eventContext,
      appContext: _appContext,
    );

    final result = await _engine.executeUIRules(rulesContext);
    await _processRulesResult(result);
  } catch (e) {
    ObslyLogger.error('Error executing UI rules: $e');
  }
}