mirrored_repositories/ApiCrudAPP/lib/core
import 'package:api_crud_app/core/errors/failures.dart';
import 'package:dartz/dartz.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

extension FoldExtension on Cubit {
  Future<T?> foldAsync<T>(
    Future<Either<Failure, T>> Function() result,
  ) async {
    final response = await result();

    return response.fold(
      (l) => throw l,
      (r) => r,
    );
  }
}
