Exemple #1
0
 public static Future <B> Select <A, B>(this Future <A> fa, Fn <A, B> f) => fa.map(f);
Exemple #2
0
 public static Future <Option <To> > mapO <From, To>(
     this Future <Option <From> > future, Fn <From, To> mapper
     )
 {
     return(future.map(opt => opt.map(mapper)));
 }
Exemple #3
0
 public static Future <A> flatten <A>(this Future <Future <A> > future) =>
 future.flatMap(_ => _);
Exemple #4
0
 public static Future <Option <A> > ofSuccess <A>(this Future <Try <A> > future) =>
 future.map(e => e.value);
Exemple #5
0
 public static Future <Option <Exception> > ofFailure <A>(this Future <Try <A> > future) =>
 future.map(e => e.exception);
Exemple #6
0
 public void WhenSuccessful()
 {
     Future <int> .successful(1).map(mapper).shouldBeSuccessful(2);
 }
Exemple #7
0
 public static Future <Option <A> > extractOpt <A>(this Option <Future <A> > futureOpt) =>
 futureOpt.fold(() => Future.successful(F.none <A>()), f => f.map(F.some));
Exemple #8
0
 public static void shouldBeSuccessful <A>(this Future <A> f, A a)
 {
     f.type.shouldEqual(FutureType.Successful);
     f.shouldBeCompleted(a);
 }
Exemple #9
0
 public static void shouldBeUnfulfilled <A>(this Future <A> f, string message = null)
 {
     f.type.shouldEqual(FutureType.Unfulfilled, message);
     f.value.shouldBeNone($"{message ?? ""}: it shouldn't have a value");
 }
Exemple #10
0
 public static IEnumerable <Future <A> > addUnfulfilled <A>(this IEnumerable <Future <A> > futures)
 {
     return(futures.Concat(Future.unfulfilled <A>().Yield()));
 }
Exemple #11
0
 public void UnfulfilledToASync()
 {
     unfulfilledShouldNotCallMapper(i => Future.a <int>(p => {}));
 }
Exemple #12
0
 public static Functional.Lazy <Option <A> > toLazy <A>(this Future <A> f) =>
 F.lazy(() => f.value);
Exemple #13
0
 public static Future <C> SelectMany <A, B, C>(this Future <A> fa, Fn <A, Future <B> > f, Fn <A, B, C> g) =>
 fa.flatMap(f, g);
Exemple #14
0
 public static Future <B> SelectMany <A, B>(this Future <A> fa, Fn <A, Future <B> > f) => fa.flatMap(f);
Exemple #15
0
 void CompleteToComplete()
 {
     Future.successful(3).collect(i => F.some(i * 2)).shouldBeCompleted(6);
 }
Exemple #16
0
 public void WhenBothSidesSuccessful()
 {
     Future.successful(1).zip(Future.successful(2)).shouldBeSuccessful(F.t(1, 2));
 }
Exemple #17
0
 void NotCompleteToNotComplete()
 {
     Future.unfulfilled <int>().collect(i => F.none <int>()).shouldNotBeCompleted();
     Future.unfulfilled <int>().collect(F.some).shouldNotBeCompleted();
 }
Exemple #18
0
 public static void shouldBeCompleted <A>(this Future <A> f, A a)
 {
     f.value.shouldBeSome(a, "it should have a value");
 }
Exemple #19
0
 public static Future <A> extract <A>(this Future <Option <A> > optFuture) =>
 optFuture.flatMap(opt => opt.fold(Future <A> .unfulfilled, Future.successful));
Exemple #20
0
 public static void shouldNotBeCompleted <A>(this Future <A> f)
 {
     f.value.shouldBeNone("it should not have a value");
 }
Exemple #21
0
 public static Future <Option <B> > ofSuccess <A, B>(this Future <Either <A, B> > future) =>
 future.map(e => e.rightValue);
Exemple #22
0
 public void CompleteToNotComplete()
 {
     Future.successful(3).filter(i => false).shouldNotBeCompleted();
 }
Exemple #23
0
 public static Future <Option <A> > ofFailure <A, B>(this Future <Either <A, B> > future) =>
 future.map(e => e.leftValue);
Exemple #24
0
 void CompleteToComplete()
 {
     Future.successful(3).filter(i => true).shouldBeCompleted(3);
 }
Exemple #25
0
 public static LazyVal <Option <A> > toLazy <A>(this Future <A> f) =>
 F.lazy(() => f.value);
Exemple #26
0
 void NotCompleteToNotComplete()
 {
     Future.unfulfilled <int>().filter(i => false).shouldNotBeCompleted();
     Future.unfulfilled <int>().filter(i => true).shouldNotBeCompleted();
 }
Exemple #27
0
 public static Future <Either <Err, To> > mapE <From, To, Err>(
     this Future <Either <Err, From> > future, Fn <From, To> mapper
     )
 {
     return(future.map(e => e.mapRight(mapper)));
 }
Exemple #28
0
 public void CompleteToNotComplete()
 {
     Future.successful(3).collect(i => F.none <int>()).shouldNotBeCompleted();
 }
Exemple #29
0
 /** Complete the future with the right side, never complete if left side occurs. **/
 public static Future <B> dropError <A, B>(this Future <Either <A, B> > future) =>
 Future.a <B>(p => future.onSuccess(p.complete));
Exemple #30
0
 public static ASyncNAtATimeQueue <Params, Return> a <Params, Return>(
     Act <Params, Promise <Return> > execute, ushort maxTasks = 1
     ) => new ASyncNAtATimeQueue <Params, Return>(
     maxTasks,
     p => Future <Return> .async(promise => execute(p, promise))
     );