public IObservable<IChangeSet<TObject, TKey>> Run() { return Observable.Create<IChangeSet<TObject, TKey>>( observer => { var filterer = new PLinqFilteredUpdater(_filter, _parallelisationOptions); return _source.Select(filterer.Update).NotEmpty().SubscribeSafe(observer); }); }
/// <summary> /// Filters the stream using the specified predicate /// </summary> /// <typeparam name="TObject">The type of the object.</typeparam> /// <typeparam name="TKey">The type of the key.</typeparam> /// <param name="source">The source.</param> /// <param name="filter">The filter.</param> /// <param name="parallelisationOptions">The parallelisation options.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">source</exception> public static IObservable <IChangeSet <TObject, TKey> > Filter <TObject, TKey>(this IObservable <IChangeSet <TObject, TKey> > source, Func <TObject, bool> filter, ParallelisationOptions parallelisationOptions) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (filter == null) { return(source); } return(Observable.Create <IChangeSet <TObject, TKey> >( observer => { var filterer = new PLinqFilteredUpdater <TObject, TKey>(filter, parallelisationOptions); return source .Select(filterer.Update) .NotEmpty() .SubscribeSafe(observer); })); }