updateResult<T> method

void updateResult<T>({
  1. required Result result,
  2. BaseComputeResult? compute,
})

Implementation

void updateResult<T>({required Result result, BaseComputeResult? compute}) {
  if (result.valid) {
    dynamic data = result.model ?? result.models.toList();
    if (data == null || (data is List && data.isEmpty)) {
      compute != null
          ? compute(null, RxStatus.empty())
          : change(null, status: RxStatus.empty());
    } else {
      compute != null
          ? compute(data, RxStatus.success())
          : change(data, status: RxStatus.success());
    }
  } else {
    compute != null
        ? compute(null, RxStatus.error(result.message))
        : change(null, status: RxStatus.error(result.message));
  }
}