Наследование: ReactiveUI.ReactiveObject
Пример #1
0
        public MainViewModel(RxSpySessionModel model)
        {
            Model = model;

            this.WhenAnyValue(x => x.Model.TrackedObservables)
                .ToProperty(this, x => x.TrackedObservables, out _trackedObservables);

            GridViewModel = new RxSpyObservablesGridViewModel(model.TrackedObservables);

            this.WhenAnyValue(x => x.GridViewModel.SelectedItem)
                .Select(x => x == null ? null : x.Model)
                .ToProperty(this, x => x.SelectedObservable, out _selectedObservable);

            this.WhenAnyValue(x => x.SelectedObservable)
                .Select(x => x == null ? null : new RxSpyObservableDetailsViewModel(x))
                .ToProperty(this, x => x.DetailsViewModel, out _detailViewModel);

            var throttledSignalCount = this.WhenAnyValue(x => x.Model.SignalCount)
                .Throttle(TimeSpan.FromSeconds(1), RxApp.MainThreadScheduler)
                .Publish()
                .RefCount();

            throttledSignalCount
                .Scan(Tuple.Create(0L, 0L), (acc, cur) => Tuple.Create(acc.Item2, cur))
                .Select(x => (double)(x.Item2 - x.Item1))
                .ToProperty(this, x => x.SignalsPerSecond, out _signalsPerSecond);

            throttledSignalCount.ToProperty(this, x => x.SignalCount, out _signalCount);

            this.WhenAnyValue(x => x.Model.ErrorCount)
                .Throttle(TimeSpan.FromSeconds(1), RxApp.MainThreadScheduler)
                .ToProperty(this, x => x.ErrorCount, out _errorCount);
        }
Пример #2
0
        public MainViewModel(RxSpySessionModel model)
        {
            Model = model;

            this.WhenAnyValue(x => x.Model.TrackedObservables)
            .ToProperty(this, x => x.TrackedObservables, out _trackedObservables);

            GridViewModel = new RxSpyObservablesGridViewModel(model.TrackedObservables);

            this.WhenAnyValue(x => x.GridViewModel.SelectedItem)
            .Select(x => x == null ? null : x.Model)
            .ToProperty(this, x => x.SelectedObservable, out _selectedObservable);

            this.WhenAnyValue(x => x.SelectedObservable)
            .Select(x => x == null ? null : new RxSpyObservableDetailsViewModel(x))
            .ToProperty(this, x => x.DetailsViewModel, out _detailViewModel);

            var throttledSignalCount = this.WhenAnyValue(x => x.Model.SignalCount)
                                       .Throttle(TimeSpan.FromSeconds(1), RxApp.MainThreadScheduler)
                                       .Publish()
                                       .RefCount();

            throttledSignalCount
            .Scan(Tuple.Create(0L, 0L), (acc, cur) => Tuple.Create(acc.Item2, cur))
            .Select(x => (double)(x.Item2 - x.Item1))
            .ToProperty(this, x => x.SignalsPerSecond, out _signalsPerSecond);

            throttledSignalCount.ToProperty(this, x => x.SignalCount, out _signalCount);

            this.WhenAnyValue(x => x.Model.ErrorCount)
            .Throttle(TimeSpan.FromSeconds(1), RxApp.MainThreadScheduler)
            .ToProperty(this, x => x.ErrorCount, out _errorCount);
        }