Esempio n. 1
0
        /// <summary>
        /// Sets the collection to be processed by this behaviour
        /// </summary>
        /// <param name="collection"></param>
        public void SetCollection(IReactiveCollection <T> collection)
        {
            // Delete previous collection and views
            ClearSubscriptions();
            DestroyAllViews();

            subscriptions = new CompositeDisposable();
            collection.ObserveAdd().Subscribe(evt => ProcessAdd(evt.Value)).AddTo(subscriptions);
            collection.ObserveRemove().Subscribe(evt => ProcessRemove(evt.Value)).AddTo(subscriptions);
            collection.ObserveReset().Subscribe(ProcessReset).AddTo(subscriptions);

            // Add all initial objects
            foreach (var model in collection)
            {
                ProcessAdd(model);
            }
        }
Esempio n. 2
0
 //用于重新搜索全表
 public static UniRx.IObservable <IReactiveCollection <T> > ObserveItemChanged <T>(this IReactiveCollection <T> reactCollection)
 {
     return(reactCollection.ObserveAdd().CombineLatest(reactCollection.ObserveRemove(), reactCollection.ObserveMove(), reactCollection.ObserveReplace(), reactCollection.ObserveReset(),
                                                       (add, remove, move, replace, reset) =>
     {
         return reactCollection;
     }));
 }