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