This library is available from NuGet.org.
A light weight .NET Standard library that provides a DisposeWith
extension method to IDisposable
objects. This is an alternative to the method provided by ReativeUI, allowing for a much smaller library dependency.
See the changelog for changes and roadmap.
An extension method for IDisposable
objects that will add the object to the given CompositeDisposable
specified.
public class MyClass
{
private readonly CompositeDisposable cd = new CompositeDisposable();
public MyClass()
{
Observable.FromEventPattern<PropertyChangedEventHandler, PropertyChangedEventArgs>(
x => response.PropertyChanged += x,
x => response.PropertyChanged -= x)
.Where(x => x.EventArgs.PropertyName == nameof(MyProperty))
.Subscribe(_ => DoSomething())
.DisposeWith(cd);
}
}