executeHooks method
Execute all matching hooks for an event.
Implementation
Future<HookResult> executeHooks({
required HookEvent event,
Map<String, dynamic> input = const {},
}) async {
final matchers = _hooks[event] ?? [];
for (final matcher in matchers) {
// Check matcher condition
if (matcher.matcher != null && matcher.matcher!.isNotEmpty) {
if (!_matchesCondition(matcher.matcher!, input)) continue;
}
for (final hook in matcher.hooks) {
// Check if condition
if (hook.condition != null) {
if (!_evaluateCondition(hook.condition!, input)) continue;
}
// Check once
final hookId = '${event.name}_${hook.hashCode}';
if (hook.once && _executedOnceIds.contains(hookId)) continue;
// Execute
final result = await _executeHook(hook, input);
if (hook.once) _executedOnceIds.add(hookId);
if (!result.shouldContinue) return result;
}
}
return const HookResult();
}