public MainViewModel() { _dataService = new DataSerivce(); _rootList = new ReactiveList <TodoItem>(); Items = _rootList.CreateDerivedCollection(x => x, x => !ShowTodoOnly || x.Done == false, (x, y) => x.DueDate.CompareTo(y.DueDate)); this.ObservableForProperty(x => x.ShowTodoOnly) .Subscribe(_ => { Items = _rootList.CreateDerivedCollection(x => x, x => !ShowTodoOnly || x.Done == false, (x, y) => x.DueDate.CompareTo(y.DueDate)); }); // Subscribe to the count changed observable so we can update our Count property. Items.CountChanged.Subscribe(x => Count = x); _dataService.Listen() .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => { _rootList.Add(x); }); Load(10); }
public MainViewModel() { _dataService = new DataSerivce(); Items = new ReactiveList <TodoItem>(); // Subscribe to the count changed observable so we can update our Count property. Items.CountChanged.Subscribe(x => Count = x); // Simply listen to each item as they come in _dataService.Listen() .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => { using (Items.SuppressChangeNotifications()) { Items.Add(x); } }); // Buffer incoming data and add them as ranges //_dataService.Listen() // .Buffer(TimeSpan.FromSeconds(10), 50) // .ObserveOn(RxApp.MainThreadScheduler) // .Subscribe(x => //{ // Items.AddRange(x); //}); // Manually handle the suspending and resetting the list //_dataService.Listen() // .Buffer(TimeSpan.FromSeconds(3), 500) // .ObserveOn(RxApp.MainThreadScheduler) // .Subscribe(x => // { // using (Items.SuppressChangeNotifications()) // { // foreach (var item in x) // { // Items.Add(item); // } // } // if (x.Any()) // { // Items.Reset(); // } // }); Load(10); }