Rok
Rok

Reputation: 705

ReactiveCommand IsExecuting changes to false after first emitted value

I created a reactive command from a cold observable. When command is invoked it changes IsExecuting to true and on first emitted value from observable back to false.

public class MyViewModel : ReactiveObject
{
    public ReactiveCommand<Unit, long> FooCommand { get; }

    private readonly ObservableAsPropertyHelper<long> _intervals;

    public long Intervals => _intervals.Value;

    public MyViewModel()
    {
        FooCommand = ReactiveCommand.CreateFromObservable(
            () => Observable.Interval(TimeSpan.FromMilliseconds(250))
            .TakeUntil(DateTimeOffset.Now.AddSeconds(2)));
        _intervals = FooCommand.ToProperty(this, vm => vm.Intervals);
    }
}

Shouldn't the IsExecuting change back to false after the observable completes and not on first emitted item? What am I missing here?

Note that I use binding in XAML if that somehow affects the behavior.

Upvotes: 1

Views: 490

Answers (1)

Daniel Vistisen
Daniel Vistisen

Reputation: 66

Correct. The IsExecuting should change back when the observable completes. It's a bug.

Source: https://github.com/reactiveui/ReactiveUI/issues/1244

Should be fixed but not in the current version (7.1.0).

Upvotes: 3

Related Questions