Ejemplo n.º 1
0
 /// <summary>
 /// Load chats into observable cache
 /// </summary>
 private IDisposable LoadChats(IChatLoader chatLoader, IAvatarLoader avatarLoader)
 {
     return(chatLoader.LoadChats()
            .Select(GetChatEntryModel)
            .Aggregate(new List <EntryModel>(), (list, model) =>
     {
         model.Order = list.Count;
         list.Add(model);
         return list;
     })
            .Synchronize(_chats)
            .Do(entries =>
     {
         _chats.EditDiff(entries, (m1, m2) => m1.Id == m2.Id);
         _chats.Refresh();
     })
            .SelectMany(entries => entries)
            .SelectMany(entry => LoadAvatar(avatarLoader, entry)
                        .Select(avatar => new
     {
         Entry = entry,
         Avatar = avatar
     }))
            .SubscribeOn(TaskPoolScheduler.Default)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(item =>
     {
         var entry = item.Entry;
         var avatar = item.Avatar;
         entry.Avatar = avatar;
     }));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Load chats into observable cache
        /// </summary>
        private IDisposable LoadChats()
        {
            return(_chatLoader.LoadChats()
                   .Select(GetChatEntryModel)
                   .Aggregate(new List <EntryModel>(), (list, model) =>
            {
                model.Order = list.Count;
                list.Add(model);
                return list;
            })
                   .Accept(entries =>
            {
                entries.Insert(0, HomeEntryModel.Instance);

                _chats.EditDiff(entries, (m1, m2) => m1.Id == m2.Id);
                _chats.Refresh();
            }));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Load chats into observable cache
 /// </summary>
 private IDisposable LoadChats(
     IChatLoader chatLoader)
 {
     return(chatLoader.LoadChats()
            .Select(GetChatEntryModel)
            .Aggregate(new List <EntryModel>(), (list, model) =>
     {
         model.Order = list.Count;
         list.Add(model);
         return list;
     })
            .Synchronize(_chats)
            .Accept(entries =>
     {
         _chats.EditDiff(entries, (m1, m2) => m1.Id == m2.Id);
         _chats.Refresh();
     }));
 }