首页 > 解决方案 > 有没有办法跟踪反应命令何时完成执行?

问题描述

有谁知道如何跟踪响应式命令已完成执行并连接将在此之后开始运行的方法的事实?

PS 在命令的处理程序方法末尾调用方法时的变体不适合我的情况。

提前致谢!

标签: c#reactiveui

解决方案


ReactiveCommand 有一个名为 observable 的属性IsExecuting,可用于观察命令何时执行。处理这种情况的一种方法是这样做:

YourCommand.IsExecuting
    .Skip(1) // IsExecuting has an initial value of false.  We can skip that first value
    .Where(isExecuting => !isExecuting) // filter until the executing state becomes false
    .Subscribe(_ => YourMethodCall()); // run your method now that the command is done

推荐阅读