/// <summary> /// Subscribes to the CollectionChanged event using a weak subscription. /// </summary> /// <param name="collection">The collection.</param> /// <param name="handler"> /// An action called when the collection event is raised. /// </param> /// <returns>A disposable used to terminate the subscription.</returns> public static IDisposable WeakSubscribe( this INotifyCollectionChanged collection, Action <NotifyCollectionChangedEventArgs> handler) { Contract.Requires <ArgumentNullException>(collection != null); Contract.Requires <ArgumentNullException>(handler != null); return(collection.GetWeakCollectionChangedObservable().Subscribe(handler)); }
/// <summary> /// Subscribes to the CollectionChanged event using a weak subscription. /// </summary> /// <param name="collection">The collection.</param> /// <param name="handler"> /// An action called when the collection event is raised. /// </param> /// <returns>A disposable used to terminate the subscription.</returns> public static IDisposable WeakSubscribe( this INotifyCollectionChanged collection, Action <NotifyCollectionChangedEventArgs> handler) { _ = collection ?? throw new ArgumentNullException(nameof(collection)); _ = handler ?? throw new ArgumentNullException(nameof(handler)); return(collection.GetWeakCollectionChangedObservable().Subscribe(handler)); }