当前位置: 首页>>代码示例>>C#>>正文


C# ReactiveList.Insert方法代码示例

本文整理汇总了C#中ReactiveList.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# ReactiveList.Insert方法的具体用法?C# ReactiveList.Insert怎么用?C# ReactiveList.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ReactiveList的用法示例。


在下文中一共展示了ReactiveList.Insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RecentViewModel

        public RecentViewModel(Guid id, string metaDataSlug, IEnumerable<RecentItemViewModel> recentItems) {
            _id = id;
            RecentItems = new ReactiveList<RecentItemViewModel>(recentItems);

            // TODO: This is a tab, and tabs are only active while shown
            // but we want to receive these events regardless of being active or not, otherwise we are not uptodate when the user switches to us.
            // Or we need to find a different approach!
            Listen<ContentUsed>()
                .Where(x => {
                    var contentId = GetId(x.Content);
                    lock (RecentItems)
                        return _id == x.Content.GameId && RecentItems.All(r => r.Id != contentId);
                })
                .Select(x => {
                    var ri = x.Content.MapTo<RecentItemViewModel>();
                    if (x.Token != null)
                        ri.UpdateExecute(x.Token);
                    return ri;
                })
                .ObserveOnMainThread()
                .Subscribe(x => {
                    lock (RecentItems)
                        RecentItems.Insert(0, x);
                });

            Listen<RecentItemRemoved>()
                .ObserveOnMainThread()
                .Subscribe(x => {
                    lock (RecentItems) {
                        RecentItems.RemoveAll(r => r.Id == x.Content.Id);
                    }
                });

            // TODO: Stop manually moving, start auto sorting in View (ICollectionView or ReactiveDerivedCollection)...
            // Then remove this event
            Listen<ContentUsed>()
                .Select(x => {
                    var contentId = GetId(x.Content);
                    lock (RecentItems)
                        return RecentItems.FirstOrDefault(r => r.Id == contentId);
                })
                .Where(x => x != null)
                .ObserveOnMainThread()
                .Subscribe(x => {
                    lock (RecentItems)
                        RecentItems.Move(RecentItems.IndexOf(x), 0);
                });

            AddContent =
                ReactiveCommand.CreateAsyncTask(
                    async x => await RequestAsync(new OpenWebLink(ViewType.Browse, metaDataSlug)).ConfigureAwait(false));


            this.WhenActivated(d => {
                RefreshUpdated();
                d(new TimerWithoutOverlap(TimeSpan.FromMinutes(1),
                    () => RxApp.MainThreadScheduler.Schedule(RefreshUpdated)));
            });
        }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:59,代码来源:RecentViewModel.cs


注:本文中的ReactiveList.Insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。