public static UniRx.Tuple <IObservableCollection <T>, IDisposable> Filter <T>(this IObservableCollection <T> collection, Func <T, ICell <bool> > predicate) { var inorganicCollection = new InorganicCollection <T>(); var disposables = new Dictionary <T, IDisposable>(); var foreachDisp = collection.ProcessEach(objAdd => { var value = objAdd; var disp = predicate(value).Bind(b => { if (b) { if (inorganicCollection.Contains(value)) { return; } inorganicCollection.Add(value); } else { inorganicCollection.Remove(value); } }); disposables[value] = disp; }, objRemove => { inorganicCollection.Remove(objRemove); if (disposables.ContainsKey(objRemove)) { var disposable = disposables[objRemove]; disposables.Remove(objRemove); disposable.Dispose(); } else { Debug.Log("disposable is not exist"); } }); return(new UniRx.Tuple <IObservableCollection <T>, IDisposable>(inorganicCollection, foreachDisp)); }