private static IObservable <(int UnreadCount, int TotalCount)> CountMessages( IProfileDataQueryFactory queryFactory, string folderId) { return(Observable.Start(() => { using var query = queryFactory.Connect(); var unreadCount = query.MessageSummaries.Count(m => m.FolderId == folderId && !m.IsRead); var totalCount = query.MessageSummaries.Count(m => m.FolderId == folderId); return (UnreadCount: unreadCount, TotalCount: totalCount); }, RxApp.TaskpoolScheduler)); }
public void Restore() { Observable.Start(() => { using var query = _queryFactory.Connect(); var folders = query.Folders.ToList(); _sourceFolders.Edit(updater => updater.Load(folders)); }, RxApp.TaskpoolScheduler); Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(30)) .Select(_ => Unit.Default) .InvokeCommand(Synchronize) .DisposeWith(_disposables); }
private void LoadBody() { IsLoading = true; _loadSubscription?.Dispose(); _loadSubscription = Observable.Start(() => { using var query = _queryFactory.Connect(); return(query.MessageDetails.FirstOrDefault(m => m.Id == _id)); }, RxApp.TaskpoolScheduler) .ObserveOn(RxApp.MainThreadScheduler) .Do(_ => IsLoading = false) .Where(x => x != null) .Subscribe(x => { Body = x.Body; BodyType = x.BodyType; }); }
public IReadOnlyList <TKey> GetAllKeys() { using var query = _queryFactory.Connect(); return(query.ForType <TEntity>().ToList( _itemSpecification.Chain(q => q.Select(e => e.Id)))); }