using System; using System.Collections.Generic; namespace UnityEngine.InputSystem.Utilities { internal class SelectManyObservable : IObservable { private readonly IObservable m_Source; private readonly Func> m_Filter; public SelectManyObservable(IObservable source, Func> filter) { m_Source = source; m_Filter = filter; } public IDisposable Subscribe(IObserver observer) { return m_Source.Subscribe(new Select(this, observer)); } private class Select : IObserver { private SelectManyObservable m_Observable; private readonly IObserver m_Observer; public Select(SelectManyObservable observable, IObserver observer) { m_Observable = observable; m_Observer = observer; } public void OnCompleted() { } public void OnError(Exception error) { Debug.LogException(error); } public void OnNext(TSource evt) { foreach (var result in m_Observable.m_Filter(evt)) m_Observer.OnNext(result); } } } }