reactiveui

reactiveui whenany on dependency property

三世轮回 提交于 2019-12-11 14:36:33
问题 I have simple WPF app with two textboxes and ReactiveUI. I try to lookup for dependency property of first textbox by using WhenAny public partial class MainWindow : Window { public MainWindow() { RxApp.DeferredScheduler = DispatcherScheduler.Current; InitializeComponent(); Text1.WhenAny(i => i.Text, i => i.Value).Subscribe(_ => SomeMethod()); } void SomeMethod() { MessageBox.Show("Boom!"); } } My Form code is <Window x:Class="TestObservable.MainWindow" xmlns="http://schemas.microsoft.com

How to make ReactiveCommand Async ?

自古美人都是妖i 提交于 2019-12-11 11:26:16
问题 I am using ReactiveCommand to get Async behavior. According to Paul Betts comment in this discussion If you're using RxUI 5.0, just use ReactiveCommand, they are now merged and have a better API. 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); }); What am I missing? 回答1: Try: MyReactiveCommand .RegisterAsyncAction(_ => { Thread.Sleep(5000); }); And if

ObservableAsPropertyHelper - have to access Value to get it to subscribe?

流过昼夜 提交于 2019-12-11 10:23:11
问题 I recently updated my ReactiveUI nugget packages to the latest pre-release versions (v5.99.4-beta). It has been a while since I did the update, but many of my tests on ViewModel's failed. The debugger seemed to indicate that my normal sequences of Rx weren't getting subscribed to. For example: _executeSearch = ReactiveCommand.Create(); var paper = _executeSearch .Where(x => x is string) .SelectMany(x => _searchParser.GetPaperFinders(x as string)) .SelectMany(x => x.FindPaper()); paper .Select

Reactive UI how to use WhenAny using two properties?

落花浮王杯 提交于 2019-12-11 09:59:50
问题 I am trying to use WhenAny (Reactive UI) for the first time. When a Identifier =="xyz" and a IsMax field get changes, want to set a local value to true in the subscribe, this.WhenAny(x => x.IsMax, x => x.Value) .Subscribe(x => { if (Identifier == "xyz") { isOk = true; } }); but is there any other way to merge Identifier condition as well? 回答1: I'm not familiar with ReactiveUI, but if it uses the same IObservable as Reactive Extensions, then you could do this: this.WhenAny(x => x.IsMax, x => x

Is there a way to track when reactive command finished its execution?

☆樱花仙子☆ 提交于 2019-12-11 09:14:33
问题 Does anybody know how to track the fact that reactive command has finished its execution and hook up the method, which will start running after that? P.S. The variant when calling the method in the end of the command's handler method does not fit in my situation. Thanks in advance! 回答1: ReactiveCommand has an observable property called IsExecuting that can be used to observe when the command is being executed. One way to handle this case would be doing something like this: YourCommand

ToProperty and BindTo - Get initial value without Subscribing

拟墨画扇 提交于 2019-12-11 02:41:11
问题 I'm using RXUI 6 with WPF in .NET 4.5. I've been having trouble getting an initial value provided to my View when the ViewModel property it is bound to is backed by an ObservableAsPropertyHelper . According to the documentation: ToProperty / OAPH changes ObservableAsPropertyHelper no longer is itself an IObservable, use WhenAny to observe it. ObservableAsPropertyHelper now lazily Subscribes to the source only when the Value is read for the first time. This significantly improves performance

Throttle but discard results if they come too late

醉酒当歌 提交于 2019-12-11 01:22:29
问题 I'm writing a UI where the user can type in a search term and a list get continuously updated offering suggestions. My first though was that the Rx primitive Throttle was a perfect match but it gets me half there. The suggestions take a while to fetch so I get them asynchronously on not on the UI thread. The problem is that I want to discard/skip/throw away a result if the user types af the throttle time span again. For example: Time starts and the user presses a key : 0ms The throttle is set

How does ReactiveTableViewSource<TSource> work?

拟墨画扇 提交于 2019-12-11 00:47:10
问题 In our app we use ReactiveUI to follow the MVVM pattern. In one view we want to show a UITableView. Data are usually passed to a UITableView.Source but with ReactiveUI we use ReactiveTableViewSource<TSource> . What I don't understand is how I can bind my data that I got in my view model in a ReactiveList to the ReactiveTableViewSource . What we now have is that we create a table inside a UIView like this: Table = new UITableView(UIScreen.MainScreen.Bounds); Table.Source = new TableSource

Notification when ReactiveCommand completes

一曲冷凌霜 提交于 2019-12-11 00:26:40
问题 I'm trying to use ReactiveUI ReactiveCommands to switch on and off a gRPC stream that I've converted into an observable. The code shown below works to some extent - the connect button will cause the stream to connect, and I start receiving data in the onNext handler of the subscribe. The disconnect button does also disconnect the stream via the cancellation token. However, once the disconnect command is executed, I would also like to be notified so I can clear up some other state in the

How to use Reactive UI to trigger a different action following a button click vs button press (hold)

不问归期 提交于 2019-12-10 19:57:00
问题 I'm trying to implement a UI control where the user can click a button to have a thing move by a little, or hold the button down and have the thing move while the button is held down. Let's say I have Task<Unit> StartMove() , Task<Unit> StopMove() and Task<Unit> MoveStep() . The button click should perform the MoveStep() and the button hold should start the move and then stop the move immediately when the button is released. Rapid clicks (double clicks) should be ignored while the move is