示例#1
0
 public static Future <B> Select <A, B>(this Future <A> fa, Fn <A, B> f) => fa.map(f);
示例#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)));
 }
示例#3
0
 public static Future <A> flatten <A>(this Future <Future <A> > future) =>
 future.flatMap(_ => _);
示例#4
0
 public static Future <Option <A> > ofSuccess <A>(this Future <Try <A> > future) =>
 future.map(e => e.value);
示例#5
0
 public static Future <Option <Exception> > ofFailure <A>(this Future <Try <A> > future) =>
 future.map(e => e.exception);
示例#6
0
 public void WhenSuccessful()
 {
     Future <int> .successful(1).map(mapper).shouldBeSuccessful(2);
 }
示例#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));
示例#8
0
 public static void shouldBeSuccessful <A>(this Future <A> f, A a)
 {
     f.type.shouldEqual(FutureType.Successful);
     f.shouldBeCompleted(a);
 }
示例#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");
 }
示例#10
0
 public static IEnumerable <Future <A> > addUnfulfilled <A>(this IEnumerable <Future <A> > futures)
 {
     return(futures.Concat(Future.unfulfilled <A>().Yield()));
 }
示例#11
0
 public void UnfulfilledToASync()
 {
     unfulfilledShouldNotCallMapper(i => Future.a <int>(p => {}));
 }
示例#12
0
 public static Functional.Lazy <Option <A> > toLazy <A>(this Future <A> f) =>
 F.lazy(() => f.value);
示例#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);
示例#14
0
 public static Future <B> SelectMany <A, B>(this Future <A> fa, Fn <A, Future <B> > f) => fa.flatMap(f);
示例#15
0
 void CompleteToComplete()
 {
     Future.successful(3).collect(i => F.some(i * 2)).shouldBeCompleted(6);
 }
示例#16
0
 public void WhenBothSidesSuccessful()
 {
     Future.successful(1).zip(Future.successful(2)).shouldBeSuccessful(F.t(1, 2));
 }
示例#17
0
 void NotCompleteToNotComplete()
 {
     Future.unfulfilled <int>().collect(i => F.none <int>()).shouldNotBeCompleted();
     Future.unfulfilled <int>().collect(F.some).shouldNotBeCompleted();
 }
示例#18
0
 public static void shouldBeCompleted <A>(this Future <A> f, A a)
 {
     f.value.shouldBeSome(a, "it should have a value");
 }
示例#19
0
 public static Future <A> extract <A>(this Future <Option <A> > optFuture) =>
 optFuture.flatMap(opt => opt.fold(Future <A> .unfulfilled, Future.successful));
示例#20
0
 public static void shouldNotBeCompleted <A>(this Future <A> f)
 {
     f.value.shouldBeNone("it should not have a value");
 }
示例#21
0
 public static Future <Option <B> > ofSuccess <A, B>(this Future <Either <A, B> > future) =>
 future.map(e => e.rightValue);
示例#22
0
 public void CompleteToNotComplete()
 {
     Future.successful(3).filter(i => false).shouldNotBeCompleted();
 }
示例#23
0
 public static Future <Option <A> > ofFailure <A, B>(this Future <Either <A, B> > future) =>
 future.map(e => e.leftValue);
示例#24
0
 void CompleteToComplete()
 {
     Future.successful(3).filter(i => true).shouldBeCompleted(3);
 }
示例#25
0
 public static LazyVal <Option <A> > toLazy <A>(this Future <A> f) =>
 F.lazy(() => f.value);
示例#26
0
 void NotCompleteToNotComplete()
 {
     Future.unfulfilled <int>().filter(i => false).shouldNotBeCompleted();
     Future.unfulfilled <int>().filter(i => true).shouldNotBeCompleted();
 }
示例#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)));
 }
示例#28
0
 public void CompleteToNotComplete()
 {
     Future.successful(3).collect(i => F.none <int>()).shouldNotBeCompleted();
 }
示例#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));
示例#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))
     );