public static IAsyncOptionEnumerable <TValue> Where <TValue>(this IOptionEnumerable <TValue> source, Func <TValue, Task <Option <Unit> > > failurePredicate)
 => source
 .SelectAsync(value => value
              .BindAsync(success => failurePredicate
                         .Invoke(success)
                         .Map(_ => success)
                         )
              )
 .AsAsyncOptionEnumerable();
Ejemplo n.º 2
0
        public static IAsyncOptionEnumerable <TResult> Select <TSuccess, TResult>(this IOptionEnumerable <TSuccess> source, Func <TSuccess, Task <TResult> > selector)
        {
            if (selector == null)
            {
                throw new ArgumentNullException(nameof(selector));
            }

            return(source
                   .SelectAsync(result => result
                                .MatchAsync(
                                    success => Option.SomeAsync(selector.Invoke(success)),
                                    () => Task.FromResult(Option.None <TResult>())
                                    )
                                )
                   .AsAsyncOptionEnumerable());
        }