unity-atoms/Packages/Core/Runtime/Observables/ObservableUnsubscriber.cs
Adam Ramberg c3bc59259f More WIP
2020-03-02 02:26:06 +01:00

26 lines
616 B
C#

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);
}
}
}
}