13 changed files with 127 additions and 63 deletions
@ -1,13 +0,0 @@ |
|||||
// -----------------------------------------------------------------------
|
|
||||
// <copyright file="IObservableDescription.cs" company="Steven Kirk">
|
|
||||
// Copyright 2014 MIT Licence. See licence.md for more information.
|
|
||||
// </copyright>
|
|
||||
// -----------------------------------------------------------------------
|
|
||||
|
|
||||
namespace Perspex |
|
||||
{ |
|
||||
public interface IObservableDescription |
|
||||
{ |
|
||||
string Description { get; } |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,35 @@ |
|||||
|
// -----------------------------------------------------------------------
|
||||
|
// <copyright file="PerspexObject.cs" company="Steven Kirk">
|
||||
|
// Copyright 2014 MIT Licence. See licence.md for more information.
|
||||
|
// </copyright>
|
||||
|
// -----------------------------------------------------------------------
|
||||
|
|
||||
|
namespace Perspex.Reactive |
||||
|
{ |
||||
|
using System; |
||||
|
using System.Reactive; |
||||
|
using System.Reactive.Disposables; |
||||
|
|
||||
|
public sealed class PerspexObservable<T> : ObservableBase<T>, IDescription |
||||
|
{ |
||||
|
private readonly Func<IObserver<T>, IDisposable> subscribe; |
||||
|
|
||||
|
public string Description { get; } |
||||
|
|
||||
|
public PerspexObservable(Func<IObserver<T>, IDisposable> subscribe, string description) |
||||
|
{ |
||||
|
if (subscribe == null) |
||||
|
{ |
||||
|
throw new ArgumentNullException("subscribe"); |
||||
|
} |
||||
|
|
||||
|
this.subscribe = subscribe; |
||||
|
this.Description = description; |
||||
|
} |
||||
|
|
||||
|
protected override IDisposable SubscribeCore(IObserver<T> observer) |
||||
|
{ |
||||
|
return this.subscribe(observer) ?? Disposable.Empty; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue