// ----------------------------------------------------------------------- // // Copyright 2015 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- namespace Perspex.Reactive { using System; using System.Reactive; using System.Reactive.Disposables; /// /// An with an additional description. /// /// The type of the elements in the sequence. public sealed class PerspexObservable : ObservableBase, IDescription { private readonly Func, IDisposable> subscribe; /// /// Initializes a new instance of the class. /// /// The subscribe function. /// The description of the observable. public PerspexObservable(Func, IDisposable> subscribe, string description) { if (subscribe == null) { throw new ArgumentNullException("subscribe"); } this.subscribe = subscribe; this.Description = description; } /// /// Gets the description of the observable. /// public string Description { get; } /// protected override IDisposable SubscribeCore(IObserver observer) { return this.subscribe(observer) ?? Disposable.Empty; } } }