Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Reactive Extension's Where method reimplemented
public static class ObservableExtensions
{
public static IObservable<TSource> Where<TSource> (this IObservable<TSource> source, Func<TSource,bool> predicate)
{
if (source == null)
{
throw new ArgumentNullException("source");
}
if (predicate == null)
{
throw new ArgumentNullException("predicate");
}
// consider whether this should be wrapped in Observable.Defer( () => {} )
return Observable.Create<TSource>(observer =>
{
return source.Subscribe(x=>
{
bool flag = false;
try
{
flag = predicate(x);
}
catch (Exception e)
{
observer.OnError(e);
return;
}
if (flag)
{
observer.OnNext(x);
}
},
observer.OnError,
observer.OnCompleted
);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.