using System; namespace UnityEngine.InputSystem.Utilities { internal class WhereObservable : IObservable { private readonly IObservable m_Source; private readonly Func m_Predicate; public WhereObservable(IObservable source, Func predicate) { m_Source = source; m_Predicate = predicate; } public IDisposable Subscribe(IObserver observer) { return m_Source.Subscribe(new Where(this, observer)); } private class Where : IObserver { private WhereObservable m_Observable; private readonly IObserver m_Observer; public Where(WhereObservable observable, IObserver observer) { m_Observable = observable; m_Observer = observer; } public void OnCompleted() { } public void OnError(Exception error) { Debug.LogException(error); } public void OnNext(TValue evt) { if (m_Observable.m_Predicate(evt)) m_Observer.OnNext(evt); } } } }