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