public MainPageViewModel(INavigationService navigationService)
            : base(navigationService)
        {
            Title = "Todo List";

            var query = CrossCloudFirestore.Current
                        .Instance
                        .GetCollection(TodoItem.CollectionPath)
                        .OrderBy(nameof(TodoItem.CreatedAt), true);

            query.ObserveAdded()
            .Select(change => (Object: change.Document.ToObject <TodoItem>(), Index: change.NewIndex))
            .Select(t => (ViewModel: new TodoItemViewModel(t.Object), Index: t.Index))
            .Subscribe(t => TodoItems.InsertOnScheduler(t.Index, t.ViewModel))
            .AddTo(_disposables);

            query.ObserveModified()
            .Select(change => change.Document.ToObject <TodoItem>())
            .Select(todoItem => (TodoItem: todoItem, ViewModel: TodoItems.FirstOrDefault(x => x.Id == todoItem.Id)))
            .Where(t => t.ViewModel != null)
            .Subscribe(t => t.ViewModel.Update(t.TodoItem.Name, t.TodoItem.Notes))
            .AddTo(_disposables);

            query.ObserveRemoved()
            .Select(change => TodoItems.FirstOrDefault(x => x.Id == change.Document.Id))
            .Where(viewModel => viewModel != null)
            .Subscribe(viewModel => TodoItems.RemoveOnScheduler(viewModel))
            .AddTo(_disposables);

            AddCommand = new ReactiveCommand();
            AddCommand.Subscribe(() =>
            {
                navigationService.NavigateAsync <NewTodoItemPageViewModel>(useModalNavigation: true, wrapInNavigationPage: true);
            });

            SelectItemCommand = new ReactiveCommand <TodoItemViewModel>();
            SelectItemCommand.Subscribe(item =>
            {
                navigationService.NavigateAsync <TodoItemDetailPageViewModel, string>(item.Id);
            });
        }