public static ISubscription bind <A>( this IObservable <A> observable, IDisposableTracker tracker, Fn <A, Coroutine> f ) { var lastCoroutine = F.none <Coroutine>(); void stopOpt() { foreach (var c in lastCoroutine) { c.stop(); } }; var sub = observable.subscribe( NoOpDisposableTracker.instance, a => { stopOpt(); lastCoroutine = f(a).some(); } ).andThen(stopOpt); tracker.track(sub); return(sub); }
public static void onCompleteCancellable <A>(this Future <A> future, IDisposableTracker tracker, Act <A> action) => tracker.track(onCompleteCancellable(future, action));