spebbe / dartz

Functional programming in Dart
MIT License
749 stars 60 forks source link

Add catchAsync for Either #105

Open otto-dev opened 2 years ago

otto-dev commented 2 years ago

Like catching, but for async function bodies.

Usage:

  Future<Either<dynamic, FooBar>> doAsyncThings() {
    return catchAsync(() async {
      final foo = await asyncAction();
      final bar = await asyncAction();
      return foo + bar;
    });
  }