unity-atoms/Source/Observables/ObservableUnsubscriber.cs

26 lines
616 B
C#
Raw Normal View History

using System;
using System.Collections.Generic;
namespace UnityAtoms
{
public class ObservableUnsubscriber<T> : IDisposable
{
private List<IObserver<T>> _observers;
private IObserver<T> _observer;
public ObservableUnsubscriber(List<IObserver<T>> observers, IObserver<T> observer)
{
this._observers = observers;
this._observer = observer;
}
public void Dispose()
{
if (_observer != null && _observers.Contains(_observer))
{
_observers.Remove(_observer);
}
}
}
}