when<T> abstract method

Future<T> when<T>(
  1. AsyncMethodInvocator<T> function,
  2. Object target,
  3. String methodName, [
  4. ExecutableArgument? arguments,
  5. Class? targetClass,
])

Executes a function with interception support and conditional routing.

This method acts as the central dispatcher that controls whether and how interceptors are applied to a particular function call. It can manage ordered chains, invoke nested interceptors, or delegate directly to the underlying function when no applicable interceptors exist.

Parameters

  • function: The function to execute, typically the original method or a wrapped invocator.
  • target: The target object or class for which the function is being invoked.
  • arguments: (Optional) The method arguments to be passed during invocation.
  • methodName: (Optional) The name of the method being invoked, for matching or diagnostics.
  • targetClass: (Optional) The target class where the method can be found on.

@return The result of the function execution, potentially modified by interceptors.

Implementation

Future<T> when<T>(AsyncMethodInvocator<T> function, Object target, String methodName, [ExecutableArgument? arguments, Class? targetClass]);