コード例 #1
0
 public static ICell <T> AtIndex <T>(this IReactiveCollection <T> collection, int index)
 {
     return(new AnonymousCell <T>(action =>
     {
         return collection.AsCell().ListenUpdates(coll =>
         {
             action(coll.Count > index ? coll[index] : default(T));
         });
     }, () =>
     {
         var coll = collection;
         return coll.Count > index ? coll[index] : default(T);
     }));
 }
コード例 #2
0
 public static IEventStream <T> MergeCollectionOfStreams <T>(this IReactiveCollection <IEventStream <T> > collection)
 {
     return(new AnonymousEventStream <T>(action =>
     {
         var connections = new Connections();
         var disposable = new DoubleDisposable
         {
             First = connections,
         };
         disposable.Second =
             // TODO It can be done more effectively then asCell call but much more complex
             collection.AsCell().Bind(coll =>
         {
             connections.DisconnectAll();
             if (disposable.disposed)
             {
                 return;
             }
             connections.AddRange(coll.Select(item => item.Subscribe(action)));
         });
         return disposable;
     }));
 }
コード例 #3
0
 /// <summary>
 /// TODO: Refactor this. Slow, but written fast.
 /// </summary>
 public static IReactiveCollection <T> Reverse <T>(this IReactiveCollection <T> original)
 {
     return(original.AsCell().Map(list => list.GetReversed()).ToReactiveCollection());
 }
コード例 #4
0
 public static ICell <bool> ContainsReactive <T>(this IReactiveCollection <T> collection,
                                                 T item)
 {
     return(collection.AsCell().Map(c => c.Contains(item)));
 }
コード例 #5
0
 public static ICell <int> CountCell <T>(this IReactiveCollection <T> coll)
 {
     return(coll.AsCell().Map(c => c.Count));
 }