call method

Result<Value> call()

Invokes run, allowing the service to be called like a function.

In test environments, mockService from package:monart/monart_testing.dart can intercept this call and return a fixed Result without invoking run.

UserCreateService(name: 'Alice', email: 'alice@test.com').call()

Implementation

Result<Value> call() {
  if (serviceInterceptors[runtimeType] case final interceptor?) {
    return switch (interceptor()) {
      Success(:final outcomes, :final value) => Success<Value>(outcomes, value as Value),
      Failure(:final outcomes, :final context) => Failure<Value>(outcomes, context),
    };
  }
  return run();
}