コード例 #1
0
        public IObservable <IEnumerable <DynamicData> > GetAsync()
        {
            return(Observable.Create <IEnumerable <DynamicData> >(x =>
            {
                var data = TabularDataGenerator.CreateInitialSnapshot()
                           .ToArray();

                x.OnNext(data);

                return Observable.Interval(DataInterval, _schedulerService.TaskPool)
                .Finally(() => x.OnCompleted())
                .DelaySubscription(DataDelay, _schedulerService.TaskPool)
                .Synchronize(data)
                .Subscribe(_ =>
                {
                    var localCopy = data.Select(y => y.Clone())
                                    .ToArray();
                    var updates = TabularDataGenerator.CreateUpdates(localCopy);

                    x.OnNext(updates);
                    data = localCopy;
                });
            })
                   .SubscribeOn(_schedulerService.TaskPool));
        }
コード例 #2
0
        public IObservable <IEnumerable <DynamicData> > GetAsync(IScheduler scheduler)
        {
            return(Observable.Create <IEnumerable <DynamicData> >(x =>
            {
                var data = TabularDataGenerator.CreateInitialSnapshot()
                           .ToArray();

                x.OnNext(data);

                return Observable.Interval(TimeSpan.FromMilliseconds(50), scheduler)
                .Finally(() => x.OnCompleted())
                .DelaySubscription(TimeSpan.FromSeconds(3), scheduler)
                .Synchronize(data)
                .Subscribe(_ =>
                {
                    var localCopy = data.Select(y => y.Clone()).ToArray();
                    var updates = TabularDataGenerator.CreateUpdates(localCopy);

                    x.OnNext(updates);
                    data = localCopy;
                });
            })
                   .SubscribeOn(scheduler));
        }