// -----------------------------------------------------------------------
//
// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
namespace Perspex.Animation
{
using System;
///
/// Tracks the progress of an animation.
///
/// The type of the value being animated./
public class Animation : IObservable, IDisposable
{
///
/// The animation being tracked.
///
private IObservable inner;
///
/// The disposable used to cancel the animation.
///
private IDisposable subscription;
///
/// Initializes a new instance of the class.
///
/// The animation observable being tracked.
/// A disposable used to cancel the animation.
public Animation(IObservable inner, IDisposable subscription)
{
this.inner = inner;
this.subscription = subscription;
}
///
/// Cancels the animation.
///
public void Dispose()
{
this.subscription.Dispose();
}
///
/// Notifies the provider that an observer is to receive notifications.
///
/// The observer.
///
/// A reference to an interface that allows observers to stop receiving notifications
/// before the provider has finished sending them.
///
public IDisposable Subscribe(IObserver observer)
{
return this.inner.Subscribe(observer);
}
}
}