本文介绍了如何使 ReactiveCommand 异步?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 ReactiveCommand 来获取异步行为.根据 Paul Betts 在本次讨论中的评论
I am using ReactiveCommand to get Async behavior. According to Paul Betts comment in this discussion
如果您使用的是 RxUI 5.0,只需使用 ReactiveCommand,它们现在已合并并具有更好的 API.
If you're using RxUI 5.0, just use ReactiveCommand, they are now merged and have a better API.
我有以下代码来测试它是否执行异步行为.事实证明并非如此.它会冻结 UI 5 秒钟.
I have the following code to test to see if it does the Async behavior. And it turns out to be not. It freezes up the UI for 5 seconds.
MyReactiveCommand.Subscribe(s => { Thread.Sleep(5000); });我错过了什么?
推荐答案尝试:
MyReactiveCommand .RegisterAsyncAction(_ => { Thread.Sleep(5000); });如果你需要返回一个结果:
And if you need to return a result:
MyReactiveCommand .RegisterAsyncFunction(o => { Thread.Sleep(5000); return o.ToString(); }) .Subscribe(s => MessageBox.Show(string.Format("{0} was returned", s)));更多推荐
如何使 ReactiveCommand 异步?
发布评论