unity-atoms/Packages/Core/Runtime/Observables/ObservableUnsubscriber.cs
2019-10-01 17:27:22 +02:00

26 lines
618 B
C#

using System;
using System.Collections.Generic;
namespace UnityAtoms
{
internal 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);
}
}
}
}