public static IDisposable BindTo(this IObservable <bool> This, IInputLayer inputLayer, string reason) { var disableDisposable = new SerialDisposable(); return(new CompositeDisposable( disableDisposable, This.DistinctUntilChanged() .Subscribe(x => disableDisposable.Disposable = x ? null : inputLayer.Disable(reason)))); }
public static IObservable <T> DisableLayerUntilCompleted <T>(this IObservable <T> This, IInputLayer layer, string reason) => Observable.Defer(() => { var disposable = layer.Disable(reason); return(This.Finally(() => disposable.Dispose())); });