public ClientMeetingViewModel( IClientConnection clientConnection, INavigationService navigation, ISharedDataService sharedDataService, IPlatformServices platformServices) { _sharedDataService = sharedDataService; _clientConnection = clientConnection; _navigation = navigation; // Combine the meeting details and IsActive to know when to go back // We should go back when we are the active screen (IsActive == true) // and the Meeting Details are cleared out - will be null. _navSub = _clientConnection.MeetingDetails .CombineLatest(this.WhenAnyValue(vm => vm.IsActive), (det, act) => new { Details = det, IsActive = act }) // combine into anon type .Where(t => t.IsActive && t.Details == null) .Subscribe(c => _navigation.BackCommand.Execute(null)); Title = "Welcome to White Label Insurance"; // Listen for state changes from the shared model // and return the non-null ids var stateObs = sharedDataService.MeetingState .WhenAnyValue(s => s.State) .Where(s => s.HasValue) .Select(s => s.Value); // de-Nullable<T> the value since we're not null // Get the latest non-null meeting var meetingObs = this.ObservableForProperty(vm => vm.Meeting, m => m) .Where(v => v != null); // Get the latest MeetingState and combine it with the current Meeting meetingObs .CombineLatest(stateObs, Tuple.Create) // store the latest in a tuple .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(t => { // for clarity, extract the tuple var state = t.Item2; var meeting = t.Item1; // Fet the specififed tool instance by id var activeTool = meeting.Tools.First(tool => tool.ToolId == state.ToolId); // Navigate to the current page within the tool activeTool.GoToPage(state.PageNumber); // Finally, set the tool to be the active one for the meeting meeting.ActiveTool = activeTool; } ); var leaveMeetingCommand = new ReactiveCommand(); leaveMeetingCommand.Subscribe(_ => _navigation.BackCommand.Execute(null)); LeaveMeetingCommand = leaveMeetingCommand; _pdfAvailableSub = _clientConnection.PdfAvailable.ObserveOn(RxApp.MainThreadScheduler).Subscribe(async p => { var result = await _clientConnection.GetIllustrationPdfAsync(p); await platformServices.SaveAndLaunchFile(new System.IO.MemoryStream(result), "pdf"); }); }