reactiveui

The difference between Rx Throttle(…).ObserveOn(scheduler) and Throttle(…, scheduler)

亡梦爱人 提交于 2019-12-10 19:54:29
问题 I have the following code: IDisposable subscription = myObservable.Throttle(TimeSpan.FromMilliseconds(50), RxApp.MainThreadScheduler) .Subscribe(_ => UpdateUi()); As expected, UpdateUi() will always execute on the main thread. When I change the code to IDisposable subscription = myObservable.Throttle(TimeSpan.FromMilliseconds(50)) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(_ => UpdateUi()); UpdateUI() will be executed in a background thread. Why is not Throttle(...).ObserveOn(scheduler)

Why don't Bind and OneWayBind always use the main UI thread?

情到浓时终转凉″ 提交于 2019-12-10 15:24:01
问题 In my ViewModel I'll often have code like the following: public bool IsDownloading { get { return _isDownloading.Value; } } private ObservableAsPropertyHelper<bool> _isDownloading; ... FileDownloader.WhenAny(x => x.IsDownloading, x => x.Value) .ToProperty(this, x => x.IsDownloading, out _isDownloading, false, RxApp.MainThreadScheduler); Note the last RxApp.MainThreadScheduler argument - that makes sure that all updates to the IsDownloading property happen on the main UI thread. The reason for

ReactiveUI: Testing progress indicator visibility while ReactiveAsyncCommand executes

谁说我不能喝 提交于 2019-12-10 11:56:03
问题 I have a ReactiveAsyncCommand that for the moment are just sleeping for a while: public ReactiveAsyncCommand SignIn { get; private set; } //from constructor: SignIn = new ReactiveAsyncCommand(this.WhenAny(x => x.Username, x => x.Password, (u, p) => !string.IsNullOrWhiteSpace(u.Value) && !string.IsNullOrWhiteSpace(p.Value))); SignIn.RegisterAsyncAction(_ => Thread.Sleep(4000)); I want to show a progress indicator while the command executes, so I have made a property to bind its visibility

ReactiveUI View Bindings to attached property

北慕城南 提交于 2019-12-09 23:24:13
问题 This Blog Entry describes using View Bindings as a replacement for XAML Bindings. I like the convention-based wire-up: this.OneWayBind(ViewModel, x => x.FooMirror); And if I want to bind to a TextBox's Text property: this.Bind(ViewModel, x => x.SomeText, x => x.SomeText.Text); However I have an attached property which I would like to bind to (for an implementation of the attached behaviour pattern). How do I use the View Bindings syntax to bind to an attached property? 回答1: Binding doesn't

Is there a more elegant way to merge observables when return type is unimportant?

早过忘川 提交于 2019-12-09 12:41:05
问题 I have a ReactiveUI-like view model. It has several properties of different types which fire NotifyPropertyChanged events and I want to subscribe a method that will be called when any is fired, but I am not interested in actual values. My current code is a bit ugly (due to opaque true selects). Is there a way to express this which shows the intention of just caring when the event occurs? this.ObservableForProperty(m => m.PropertyOne) .Select(_ => true) .Merge(this.ObservableForProperty(m => m

What Am I Missing About Reactive Extension Timers?

天涯浪子 提交于 2019-12-08 10:04:48
问题 I have this: watchers .ToObservable() // needs to be observable .SelectMany(watcher => // working on each watcher Observable // create a timer for the watcher .Timer(watcher.StartTime, TimeSpan.FromHours(watcher.Interval)) .SelectMany(Observable.FromAsync( async () => new { watcher, result = await CheckFolder(watcher.Path) }))) .Subscribe(x => Console.WriteLine(string.Format("Watcher: {0}\tResult: {1}\tTime: {2}", x.watcher.Name, x.result, DateTimeOffset.Now))); // tell everyone what happened

ReactiveUI The calling thread cannot access this object because a different thread owns it

送分小仙女□ 提交于 2019-12-08 06:45:21
问题 If I use a binding in code behind, getting an error after click at change IsBusy "The calling thread cannot access this object because a different thread owns it" xaml: <Button x:Name="AsyncCommand" Height="20" Content="PushAsync"/> <ProgressBar x:Name="IsBusy" Height="20"/> cs: this.Bind(ViewModel, x => x.IsBusy, x => x.IsBusy.IsIndeterminate); this.BindCommand(ViewModel, x => x.AsyncCommand, x => x.AsyncCommand); viewmodel: public class TestViewModel : ReactiveObject { public TestViewModel(

Recommended way to test Scheduler/Throttle

别等时光非礼了梦想. 提交于 2019-12-07 18:29:30
问题 I'm in the process of rewriting one little WPF-App I wrote to make use of ReactiveUI, to get a feeling about the library. I really like it so far! Now I've stumbled upon the Throttle method and want to use it when applying a filter to a collection. This is my ViewModel: namespace ReactiveUIThrottle { public class MainViewModel : ReactiveObject { private string _filter; public string Filter { get => _filter; set => this.RaiseAndSetIfChanged(ref _filter, value); } private readonly ReactiveList

UICollectionView - too many update animations on one view

只愿长相守 提交于 2019-12-07 12:22:57
问题 Update: Solved! See my answer below for the solution. My app displays a number of images in a UICollectionView. And I'm currently experiencing a problem with insertItemsAtIndexPaths when new items are getting inserted too fast for the collection view to handle. Below is the exception: NSInternalInconsistencyException Reason: too many update animations on one view - limit is 31 in flight at a time Turns out this was caused by my model buffering up to 20 new images and pushing them to the

ReactiveUI and Validation

南笙酒味 提交于 2019-12-07 02:55:45
What's considered "best practice" when performing data validation while using ReactiveUI ? Let's say I have a view model that looks like this: public class MyViewModel: ReactiveObject { public ReactiveAsyncCommand SaveMyDataCommand { get; protected set; } private string _email; public string Email { get { return _email; } set { _email = value; raisePropertyChanged("Email"); } } private string _name; public string Name { get { return _name; } set { _name= value; raisePropertyChanged("Name"); } } private bool _sendEmail = false; public bool SendEmail { get { return _sendEmail; } set { _sendEmail