public ConditionViewModel(AppViewModel screen, string conditionId, string conditionName, IHealthService service) { this.HostScreen = screen; this.ConditionName = conditionName; var loadConditionFromApi = ReactiveCommand.CreateFromTask(async() => { var details = await service.GetConditionDetailsAsync(conditionId); return(details); }); loadConditionFromApi.ThrownExceptions.Subscribe(e => { Debug.WriteLine(e.Message); }); var conditionDetails = loadConditionFromApi.Publish().RefCount(); this.isLoadingProperty = loadConditionFromApi.IsExecuting.ToProperty(this, vm => vm.IsLoading); this.complicationsProperty = conditionDetails.Select(c => c.Complications).ToProperty(this, vm => vm.Complications); this.symptomsProperty = conditionDetails.Select(c => c.Symptoms.Select(s => new ConditionViewModel(screen, s.Id, s.Name, service))).ToProperty(this, vm => vm.Symptoms); this.suggestionsProperty = conditionDetails.Select(c => c.Suggestions).ToProperty(this, vm => vm.Suggestions); if (screen != null) { this.WhenNavigatedTo(() => Task.Run(async() => await loadConditionFromApi.Execute())); } this.ViewCommand = ReactiveCommand.Create(() => screen.Router.Navigate.Execute(this).Subscribe()); }