public Future <Return> query(Params parameters) { return(Future <Return> .async((p, f) => { theFuture.onComplete(_ => doQuery(parameters, p)); theFuture = f; })); }
public static IRxVal <Option <A> > toRxVal <A>(this Future <A> future) { var rx = RxRef.a(F.none <A>()); future.onComplete(a => rx.value = F.some(a)); return(rx); }
public Future <C> zip <B, C>(Future <B> fb, Fn <A, B, C> mapper) { if (implementation.isB || fb.implementation.isB) { return(Future <C> .unfulfilled); } if (implementation.isA && fb.implementation.isA) { return(Future.successful(mapper(implementation.__unsafeGetA, fb.implementation.__unsafeGetA))); } var fa = this; return(Future <C> .async(p => { void tryComplete() { foreach (var ab in fa.value.zip(fb.value, mapper)) { p.tryComplete(ab); } } fa.onComplete(a => tryComplete()); fb.onComplete(b => tryComplete()); })); }
public static void onFailure <A, B>(this Future <Either <A, B> > future, Act <A> action) => future.onComplete(e => { foreach (var a in e.leftValue) { action(a); } });
public static void onFailure <A>(this Future <Try <A> > future, Act <Exception> action) => future.onComplete(e => { foreach (var ex in e.exception) { action(ex); } });
public static void onSuccess <A, B>(this Future <Either <A, B> > future, Act <B> action) => future.onComplete(e => { foreach (var b in e.rightValue) { action(b); } });
public static void onSuccess <A>(this Future <Try <A> > future, Act <A> action) => future.onComplete(e => { foreach (var a in e.value) { action(a); } });
public static IRxVal <B> toRxVal <A, B>(this Future <A> future, B whileNotCompleted, Fn <A, B> onCompletion) { var rx = RxRef.a(whileNotCompleted); future.onComplete(a => rx.value = onCompletion(a)); return(rx); }
public static IRxVal <A> toRxVal <A>(this Future <A> future, A whileNotCompleted) { var rx = RxRef.a(whileNotCompleted); future.onComplete(a => rx.value = a); return(rx); }
public static IRxVal <A> toRxVal <A>( this Future <IRxVal <A> > future, A whileNotCompleted ) { var rx = RxRef.a(whileNotCompleted); future.onComplete(rx2 => rx2.subscribe(v => rx.value = v)); return(rx); }
public static ISubscription onCompleteCancellable <A>(this Future <A> future, Act <A> action) { var sub = new Subscription(() => { }); future.onComplete(val => { if (sub.isSubscribed) { action(val); } }); return(sub); }
/// <summary> /// Complete the future with the right side, never complete if left side occurs. /// </summary> public static Future <B> dropError <A, B>( this Future <Either <A, B> > future, bool logOnError = false ) => Future.a <B>(p => future.onComplete(either => either.voidFold( err => { if (logOnError) { Log.d.error(err.ToString()); } }, p.complete )));
public static IRxVal <A> toRxVal <A>( this Future <IRxVal <A> > future, A whileNotCompleted ) => new RxVal <A>( whileNotCompleted, setValue => { var sub = Subscription.empty; future.onComplete(rx2 => { sub = rx2.subscribe(NoOpDisposableTracker.instance, a => setValue(a)); }); return(new Subscription(() => sub.unsubscribe())); } );
public static void onComplete <A, B>( this Future <Either <A, B> > future, Act <A> onError, Act <B> onSuccess ) => future.onComplete(e => { if (e.isLeft) { onError(e.__unsafeGetLeft); } else { onSuccess(e.__unsafeGetRight); } });
public static void onFailure <A, B>(this Future <Either <A, B> > future, Act <A> action) { future.onComplete(e => e.leftValue.each(action)); }
public static void onSuccess <A, B>(this Future <Either <A, B> > future, Act <B> action) { future.onComplete(e => e.rightValue.each(action)); }