简体   繁体   English

首次发出值后,ReactiveCommand IsExecuting更改为false

[英]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. 当调用command时,它将IsExecuting更改为true,并将第一个从observable 发出的值更改回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? 在observable完成IsExecuting是否应该更改为false而不是在第一个发出的项目上? What am I missing here? 我在这里错过了什么?

Note that I use binding in XAML if that somehow affects the behavior. 请注意,如果以某种方式影响行为,我在XAML中使用绑定。

Correct. 正确。 The IsExecuting should change back when the observable completes. 当observable完成时,IsExecuting应该更改回来。 It's a bug. 这是一个错误。

Source: https://github.com/reactiveui/ReactiveUI/issues/1244 资料来源: https//github.com/reactiveui/ReactiveUI/issues/1244

Should be fixed but not in the current version (7.1.0). 应修复但不在当前版本(7.1.0)中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM