-
-
Save ajrouvoet/10869472 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
namespace System.Reactive | |
{ | |
public static class Observable | |
{ | |
/// <summary> | |
/// Creates an observable sequence object from the specified subscription function. | |
/// </summary> | |
/// <typeparam name="subscribe">Subscribe method implementation.</typeparam> | |
public static IObservable<T> Create<T>(Func<ObserverBase<T>, ISubscription> subscribe) | |
{ | |
return new AnonymousObservable<T>((obs) => obs.Add(subscribe(obs))); | |
} | |
/// <summary> | |
/// Creates an observable sequence object from the specified subscription function. | |
/// </summary> | |
/// <typeparam name="subscribe">Subscribe method implementation.</typeparam> | |
public static IObservable<T> Create<T>(Action<ObserverBase<T>> subscribe) | |
{ | |
return new AnonymousObservable<T>((obs) => subscribe(obs)); | |
} | |
/// <summary> | |
/// Creates an observable from it's arguments | |
/// </summary> | |
public static IObservable<T> Of<T>(params T[] args) | |
{ | |
return Observable.Create<T>((ObserverBase<T> obs) => obs.Of(args)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment