using System; using System.Collections.Generic; using System.Linq; using Chernobyl.Destruction; namespace Chernobyl.Unity.Event { /// /// Holds subscriptions from one to multiple /// instances. Useful with dependency injection. /// public class Subscriptions : IDisposable { /// The observable to subscribe the to. /// The that are to be subscribed to /// . public Subscriptions(IObservable observable, IEnumerable> observers) { _disposables = observers.Select(observable.Subscribe).ToArray(); } /// public void Dispose() => _disposables.Dispose(); readonly IDisposable[] _disposables; } }