Ejemplo n.º 1
0
        public static IDisposable Subscribe <T, TKey>(this IGroupedObservable <T, TKey> value, Action <T> onNext)
        {
            Observer <T> observer = new Observer <T>(onNext);
            IDisposable  subject  = value.Subscribe(observer);

            return(subject);
        }
Ejemplo n.º 2
0
        public static IDisposable Subscribe <T, TKey>(this IGroupedObservable <T, TKey> value, Action <T> onNext, Action <Exception> onError, Action onCompleted)
        {
            Observer <T> observer = new Observer <T>(onNext, onError, onCompleted);
            IDisposable  subject  = value.Subscribe(observer);

            return(subject);
        }
Ejemplo n.º 3
0
        private static IObservable <TValue> DebounceWithSelector <TKey, TValue>(this IGroupedObservable <TKey, TValue> source, TimeSpan dueTime, Func <TValue> itemSelector, IScheduler scheduler)
        {
            return(Observable.Create <TValue>(o =>
            {
                var disposables = new CompositeDisposable();
                var debounceDisposable = new SerialDisposable();

                disposables.Add(debounceDisposable);

                Action debounce = () =>
                {
                    debounceDisposable.Disposable = scheduler.Schedule(dueTime,
                                                                       () =>
                    {
                        var debouncedItem = itemSelector();
                        o.OnNext(debouncedItem);
                    });
                };

                disposables.Add(source.Subscribe(x =>
                {
                    debounce();
                    o.OnNext(x);
                },
                                                 o.OnError,
                                                 o.OnCompleted));

                debounce();

                return disposables;
            }));
        }
Ejemplo n.º 4
0
 public void OnNext(IGroupedObservable <TKey, T> value)
 {
     AddStream(value);
     value.Subscribe(data =>
     {
         /* OnNext = No-op */
     },
                     ex => DropStream(value),
                     () => DropStream(value));
 }
Ejemplo n.º 5
0
        private static void DumpGroup <T1, T2>(IGroupedObservable <T1, T2> seq)
        {
            Task.Factory.StartNew(() =>
            {
                Console.Write($"Key={seq.Key}: ");
                var ev = new ManualResetEvent(false);

                using (var s = seq.Subscribe(a => DumpValue(a), () => ev.Set()))
                {
                    ev.WaitOne();
                }
            });
        }