Ejemplo n.º 1
0
 public static ISingle <T> OnErrorReturn <T>(this ISingle <T> source, Func <T> valueSupplier)
 {
     return(Create <T>(s =>
     {
         source.Subscribe(new OnErrorReturnSingleSubscriber <T>(s, valueSupplier));
     }));
 }
Ejemplo n.º 2
0
 public static ISingle <T> OnErrorResumeNext <T>(this ISingle <T> source, Func <Exception, ISingle <T> > resumeWith)
 {
     return(Create <T>(s =>
     {
         source.Subscribe(new ResumeNextSingleSubscriber <T>(s, resumeWith));
     }));
 }
Ejemplo n.º 3
0
 public static ISingle <T> Timeout <T>(this ISingle <T> source, TimeSpan timeout, IScheduler scheduler, ISingle <T> other = null)
 {
     return(Create <T>(s =>
     {
         source.Subscribe(new TimeoutSingleSubscriber <T>(s, timeout, scheduler, other));
     }));
 }
Ejemplo n.º 4
0
 public static ISingle <T> Delay <T>(this ISingle <T> source, TimeSpan delay, IScheduler scheduler, bool delayError = false)
 {
     return(Create <T>(s =>
     {
         source.Subscribe(new DelaySingeSubscriber <T>(s, delay, scheduler, delayError));
     }));
 }
Ejemplo n.º 5
0
 public static ISingle <T> UnsubscribeOn <T>(this ISingle <T> source, IScheduler scheduler)
 {
     return(Create <T>(s =>
     {
         source.Subscribe(new UnsubscribeOnSingleSubscriber <T>(s, scheduler));
     }));
 }
Ejemplo n.º 6
0
 public static ISingle <R> Map <T, R>(this ISingle <T> source, Func <T, R> mapper)
 {
     return(Create <R>(s =>
     {
         source.Subscribe(new MapSingleSubscriber <T, R>(s, mapper));
     }));
 }
Ejemplo n.º 7
0
        public static T Get <T>(this ISingle <T> source, TimeSpan timeout)
        {
            LatchedSingleSubscriber <T> lss = new LatchedSingleSubscriber <T>();

            source.Subscribe(lss);

            return(lss.Get(timeout));
        }
Ejemplo n.º 8
0
        public static T Get <T>(this ISingle <T> source)
        {
            LatchedSingleSubscriber <T> lss = new LatchedSingleSubscriber <T>();

            source.Subscribe(lss);

            return(lss.Get());
        }
Ejemplo n.º 9
0
        public static IDisposable Subscribe <T>(this ISingle <T> source)
        {
            LambdaSingleSubscriber <T> lss = new LambdaSingleSubscriber <T>(v => { }, e => { });

            source.Subscribe(lss);

            return(lss);
        }
Ejemplo n.º 10
0
        public IDisposable Subscribe(IObserver <T> observer)
        {
            ObserverToSingleSubscriber <T> oss = new ObserverToSingleSubscriber <T>(observer);

            source.Subscribe(oss);

            return(oss);
        }
Ejemplo n.º 11
0
        public static IDisposable Subscribe <T>(this ISingle <T> source, IObserver <T> observer)
        {
            ObserverToSingleSubscriber <T> oss = new ObserverToSingleSubscriber <T>(observer);

            source.Subscribe(oss);

            return(oss);
        }
Ejemplo n.º 12
0
 public static ISingle <T> DoOnError <T>(this ISingle <T> source, Action <Exception> onErrorCall)
 {
     return(Create <T>(s =>
     {
         source.Subscribe(new LifecycleSingleSubscriber <T>(s,
                                                            d => { }, v => { }, onErrorCall, () => { }
                                                            ));
     }));
 }
Ejemplo n.º 13
0
 public static ISingle <T> DoOnSuccess <T>(this ISingle <T> source, Action <T> onSuccessCall)
 {
     return(Create <T>(s =>
     {
         source.Subscribe(new LifecycleSingleSubscriber <T>(s,
                                                            d => { }, onSuccessCall, e => { }, () => { }
                                                            ));
     }));
 }
Ejemplo n.º 14
0
 public static ISingle <T> DoOnSubscribe <T>(this ISingle <T> source, Action <IDisposable> onSubscribeCall)
 {
     return(Create <T>(s =>
     {
         source.Subscribe(new LifecycleSingleSubscriber <T>(s,
                                                            onSubscribeCall, v => { }, e => { }, () => { }
                                                            ));
     }));
 }
Ejemplo n.º 15
0
        public static ICompletable ToCompletable <T>(this ISingle <T> source)
        {
            return(Completable.Create(cs =>
            {
                SingleSubscriberToCompletableSubscriber <T> sscs = new SingleSubscriberToCompletableSubscriber <T>(cs);

                source.Subscribe(sscs);
            }));
        }
Ejemplo n.º 16
0
 public static ISingle <T> DoAfterTerminate <T>(this ISingle <T> source, Action onAfterTerminateCall)
 {
     return(Create <T>(s =>
     {
         source.Subscribe(new LifecycleSingleSubscriber <T>(s,
                                                            d => { }, v => { }, e => { }, onAfterTerminateCall
                                                            ));
     }));
 }
Ejemplo n.º 17
0
 internal void Resubscribe()
 {
     if (Interlocked.Increment(ref wip) == 1)
     {
         do
         {
             source.Subscribe(this);
         } while (Interlocked.Decrement(ref wip) != 0);
     }
 }
Ejemplo n.º 18
0
        public static IPublisher <T> ToPublisher <T>(this ISingle <T> source)
        {
            if (source is ScalarSource <T> )
            {
                return((ScalarSource <T>)source);
            }

            return(Flowable.Create <T>(s =>
            {
                source.Subscribe(new SubscriberToSingleSubscriber <T>(s));
            }));
        }
 internal void Resubscribe()
 {
     if (Interlocked.Increment(ref wip) == 1)
     {
         do
         {
             if (--remaining <= 0)
             {
                 return;
             }
             source.Subscribe(this);
         } while (Interlocked.Decrement(ref wip) != 0);
     }
 }
Ejemplo n.º 20
0
        public static ISingle <bool> Equals <T>(this ISingle <T> first, ISingle <T> second)
        {
            return(Create <bool>(s =>
            {
                T[] array = new T[2];
                int[] counter = { 2 };
                SetCompositeDisposable all = new SetCompositeDisposable();

                s.OnSubscribe(all);

                first.Subscribe(new EqualsSingleSubscriber <T>(s, 0, array, counter, all));
                second.Subscribe(new EqualsSingleSubscriber <T>(s, 1, array, counter, all));
            }));
        }
Ejemplo n.º 21
0
        public static ISingle <T> SubscribeOn <T>(this ISingle <T> source, IScheduler scheduler)
        {
            return(Create <T>(s =>
            {
                MultipleAssignmentDisposable inner = new MultipleAssignmentDisposable();

                MultipleAssignmentDisposable mad = new MultipleAssignmentDisposable(inner);

                inner.Set(scheduler.ScheduleDirect(() =>
                {
                    source.Subscribe(new SingleSubscriberWrapper <T>(s, mad));
                }));
            }));
        }
Ejemplo n.º 22
0
        public void Subscribe(ISingleSubscriber <R> s)
        {
            ISingleSubscriber <T> sr;

            try
            {
                sr = onLift(s);
            }
            catch (Exception ex)
            {
                EmptyDisposable.Error(s, ex);
                return;
            }
            source.Subscribe(sr);
        }
Ejemplo n.º 23
0
        public static ISingle <T> DelaySubscription <T>(this ISingle <T> source, TimeSpan delay, IScheduler scheduler)
        {
            return(Create <T>(s =>
            {
                MultipleAssignmentDisposable inner = new MultipleAssignmentDisposable();

                MultipleAssignmentDisposable mad = new MultipleAssignmentDisposable(inner);

                s.OnSubscribe(mad);

                inner.Set(scheduler.ScheduleDirect(() => {
                    source.Subscribe(new SingleSubscriberWrapper <T>(s, mad));
                }, delay));
            }));
        }
 void DoSubscribe()
 {
     source.Subscribe(this);
 }
Ejemplo n.º 25
0
 public static void Subscribe <T>(this ISingle <T> source, ISubscriber <T> subscriber)
 {
     source.Subscribe(new SubscriberToSingleSubscriber <T>(subscriber));
 }
Ejemplo n.º 26
0
 public static ISingle <T> AsSingle <T>(this ISingle <T> source)
 {
     return(Create <T>(s => source.Subscribe(s)));
 }
 public void OnComplete()
 {
     second.Subscribe(this);
 }