Esempio n. 1
0
        public static IDisposable BindProvider(
            this CatalogModel model,
            ICatalogProvider provider)
        {
            var entries = model.Entries;
            var filter  = model.FilterController;
            var sorting = model.SortingController;

            return(provider.Chats.Connect()
                   .Filter(filter)
                   .Sort(sorting)
                   .SubscribeOn(RxApp.TaskpoolScheduler)
                   .ObserveOn(RxApp.MainThreadScheduler)
                   .Bind(entries)
                   .Accept());
        }
Esempio n. 2
0
        public static IDisposable BindFilter(
            this CatalogModel model,
            Section section)
        {
            return(model.WhenAnyValue(m => m.SearchText)
                   .Throttle(TimeSpan.FromMilliseconds(500))
                   .Accept(text =>
            {
                var sorting = GetSorting(e => e.Order);
                var filter = GetFilter(section);

                if (!string.IsNullOrWhiteSpace(text))
                {
                    sorting = GetSorting(e => e.Title);

                    filter = entry =>
                             entry.Title.Contains(text) &&
                             GetFilter(section)(entry);
                }

                model.SortingController.OnNext(sorting);
                model.FilterController.OnNext(filter);
            }));
        }