public HistoryViewModel() { Title = "History"; _dataRepository = Locator.Current.GetService <IDataRepository>(); LoadHistory = ReactiveCommand.CreateFromTask <Unit, Unit>(async _ => { await _dataRepository.GetItemsAsync(); return(Unit.Default); }); _dataRepository .History .Connect() .SubscribeOn(TaskPoolScheduler) .ObserveOn(TaskPoolScheduler) .Transform(movie => new HistoryCellViewModel(movie)) .DisposeMany() .ObserveOn(MainThreadScheduler) .Bind(out _history) .Subscribe(); LoadHistory.Subscribe(); LoadHistory.Execute(); _isRefreshing = LoadHistory .IsExecuting .ToProperty(this, x => x.IsRefreshing, true); }
public void OnLoadHistory() { LoadHistory?.Invoke(); }