ReactiveUI icon indicating copy to clipboard operation
ReactiveUI copied to clipboard

ReactiveCommand not working when predicate refers to an ObservableAsPropertyHelper

Open mmamone opened this issue 10 years ago • 2 comments

I'm currently having a problem with a ReactiveCommand predicate (using ReactiveUI 6.2, in a WPF application). I have a property called LoggedIn, backed by an ObservableAsPropertyHelper, and it's defined like this :

someObservableThatReturnsBoolean
    .ToProperty(this, x => x.LoggedIn, out _loggedIn)

I then have a ReactiveCommand that uses that property as a predicate :

var command = ReactiveCommand.Create(this.WhenAnyValue(x => x.LoggedIn))

However, when LoggedIn becomes false, the command may still be executed. If I changed LoggedIn to be a regular property :

someObservableThatReturnsBoolean
    .Subscribe(b => LoggedIn = b)

then the command behaves as expected.

I notice that this happens when there are multiple "instances" of a this.WhenAnyValue(...) pointing to the same ObservableAsPropertyHelper property.

mmamone avatar Feb 04 '16 22:02 mmamone

Can you create a small sample that reproduces this issue?

flagbug avatar Apr 12 '16 15:04 flagbug

Closed due to no response.

kentcb avatar May 27 '17 09:05 kentcb