Last active
May 27, 2018 14:46
-
-
Save akarnokd/6638bbfd89df9e5d4848d7d6489cbc22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace System.Reactive.Linq | |
{ | |
/// <summary> | |
/// Provides a set of static methods for writing in-memory queries over observable sequences. | |
/// </summary> | |
public static class ObservableEx | |
{ | |
private static IQueryLanguageEx _override; | |
/// <summary> | |
/// Override the default implementation of operators. | |
/// </summary> | |
public static IQueryLanguageEx Override | |
{ | |
get { return Volatile.Read(ref _override); } | |
set { Interlocked.Exchange(ref _override, value); } | |
} | |
[Experimental] | |
public static IObservable<TResult> Create<TResult>(Func<IObserver<TResult>, IEnumerable<IObservable<object>>> iteratorMethod) | |
{ | |
if (iteratorMethod == null) | |
throw new ArgumentNullException(nameof(iteratorMethod)); | |
var ovr = Override; | |
if (ovr != null) | |
{ | |
return ovr.Create(iteratorMethod); | |
} | |
return new AnonymousObservable<TResult>(observer => | |
iteratorMethod(observer).Concat().Subscribe(_ => { }, observer.OnError, observer.OnCompleted)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment