public SelectedCallsScreenViewModel(ISelectionService selectionService, IConcurrencyService concurrencyService, IObservablesList observablesListViewModel) { ObservablesList = observablesListViewModel; DisplayName = "IObservable instances"; observablesListViewModel.Observables = selectionService.WhenSelectionChanges .ObserveOn(concurrencyService.TaskPoolRxScheduler) .Select(selection => selection.SelectedInstrumentedCalls) .DistinctUntilChanged() .Select(calls => calls .Select(c => c.ObservableInstances) .Merge() .ToObservableChangeSet(obs => obs.ObservableId)) .SwitchFixed(); this.WhenActivated((CompositeDisposable disposables) => { observablesListViewModel.WhenSelectionChanges .OnItemAdded(obs => selectionService.ChangeSelection(s => s.AddObservableInstance(obs))) .OnItemRemoved(obs => selectionService.ChangeSelection(s => s.RemoveObservableInstance(obs))) .Subscribe() .DisposeWith(disposables); observablesListViewModel.Activator.Activate() .DisposeWith(disposables); }); }
public ObservablesScreenViewModel(IObservablesList observablesList, IMarbleDiagramScreen marbleDiagram) { ObservablesList = observablesList; DetailContent = marbleDiagram; this.WhenActivated((CompositeDisposable disposables) => { marbleDiagram.ObservableInstances = observablesList.WhenSelectionChanges; observablesList.Activator.Activate().DisposeWith(disposables); marbleDiagram.Activator.Activate().DisposeWith(disposables); }); }