call method

  1. @override
FutureOr<Object?> call(
  1. String function,
  2. Object? input,
  3. BallCallable engine
)
override

Executes function with the given input value.

engine is a BallCallable that lets this handler compose other ball functions (user-defined or from other handlers) without holding a direct engine reference:

final sub = engine('std', 'subtract',
    {'left': highPrice, 'right': lowPrice});

Throws BallRuntimeError when function is not supported.

Implementation

@override
FutureOr<Object?> call(String function, Object? input, BallCallable engine) {
  final composed = _composedDispatch[function];
  if (composed != null) return composed(input, engine);
  final handler = _dispatch[function];
  if (handler == null) {
    throw BallRuntimeError('Unknown std function: "$function"');
  }
  return handler(input);
}