when<R> method

R when<R>({
  1. required R success(
    1. T data
    ),
  2. required R failure(
    1. String error
    ),
})

Implementation

R when<R>({
  required R Function(T data) success,
  required R Function(String error) failure,
}) {
  if (isSuccess) {
    return success(data as T);
  } else {
    return failure(error!);
  }
}