perform method

  1. @override
Future<BlocxUseCaseResult<Output>> perform(
  1. Input input
)
override

The business logic implementation.

Called by execute. Throw freely — exceptions are caught and converted to BlocxUseCaseFailure automatically.

Return values via success:

return success(myOutput);

Implementation

@override
Future<BlocxUseCaseResult<Output>> perform(Input input) async {
  recordedInputs.add(input);
  if (delay > Duration.zero) await Future<void>.delayed(delay);
  if (completer != null) await completer!.future;
  if (shouldFail) throw failureError ?? Exception('UseCase task failed');
  final result = handler != null ? handler!(input) : returnValue as Output;
  return success(result);
}