spebbe / dartz

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

Add catchAsync for Eithers #106

Open otto-dev opened 2 years ago

otto-dev commented 2 years ago

Closes #105. Allows to use catchAsync in place of catching for asynchronous contexts.

Example usage:

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

Went for catchAsync instead of catchingAsync.