processNavigationEvent method
Execute rules for navigation events with fresh appContext
Implementation
Future<void> processNavigationEvent(ObslyEventBase event) async {
if (!_isAvailable || !_isExecutionEnabled) return;
try {
final navContext = _extractNavigationContext(event);
if (navContext != null) {
// Build fresh appContext for this evaluation
final currentAppContext = _buildCurrentAppContext();
// Merge navigation context with app context
final fullContext = {
...currentAppContext,
'navigation': {
'from': navContext['fromRoute'] ?? '',
'to': navContext['toRoute'] ?? '',
'arguments': navContext['routeArguments'] ?? {},
},
};
// Use unified execution method
await RulesManager.instance.executeRulesForEvent(
eventType: 'navigation',
context: fullContext,
);
ObslyLogger.log('🧭 Navigation Rules executed: ${navContext['fromRoute']} -> ${navContext['toRoute']}');
}
} catch (e) {
ObslyLogger.error('Error executing navigation rules: $e');
}
}