Menu
  • HOME
  • TAGS

Correct way to use ObservableAsPropertyHelper and this.WhenAny on a ViewModel

mvvm,reactiveui

I think that the SelectedTool state variable should be readonly and set upon the tool selection (should this be ObservableAsPropertyHelper?) I would actually drive this the other way around - the SelectedTool as an Enum should be the Source Of Truthâ„¢, and have the button state be a reflection...

Simple reactive list binding fails in 6.5.0 version of ReactiveUI on WPF

c#,wpf,reactiveui

The thing with ReactiveUI when you bind to things like a ListBox using the OneWayBind method, is that it will try to automatically apply a custom template for the data based upon the views it finds with Splat.Locator.Resolve. In your case, it is trying to find and build a view...

Howto let ReactiveCommands observe their own IsExecuting observable

c#,mvvm,system.reactive,reactiveui

I would set up a proxy via using a Subject: var areAllAvailable = new BehaviorSubject<bool>(true); PauseCommand = new ReactiveCommand(areAllAvailable); PlayCommand = new ReactiveCommand(areAllAvailable); Observable.CombineLatest(PauseCommand.IsExecuting, PlayCommand.IsExecuting, (pa,pl) => !(pa || pl)) .Subscribe(allAreAvailable); ...

Controlling the max thread count of SelectMany

c#,system.reactive,reactiveui

Merge has a max parallelism parameter: AsyncCommand = ReactiveCommand.CreateAsyncObservable(_ => { // Set progress bar indicator to 0 var set = new [] {...} // The set of items to process // Set the progress bar indicator max to the count of the items to process return set .ToObservable() .Select(item...

What is the best way to call async methods using reactiveui + throttle

c#,system.reactive,reactiveui

You must call Subscribe either way. Queries in Rx use lazy evaluation, which means that merely defining a query does not start it. Lazy evaluation allows you to build a query by applying operators conditionally, to define a query only once and store it in a field for later, or...

Rx extensions Parallel.ForEach throttling

c#,parallel-processing,system.reactive,reactiveui

As usual, Paul Betts has answered a similar question that solves my problem: The question: Reactive Extensions Parallel processing based on specific number Has some information on using Observable.Defer and then merging into batches, using that I've modified my previous code like so: return inputs.Select(i => new AccountViewModel(i)) .ToObservable() .ObserveOn(RxApp.MainThreadScheduler)...

Bind IBitmap to ImageView

xamarin,monodroid,reactiveui

So as usual it was the programmer's problem. :D This is the way I did it now and I'm quite happy with the solution. I missed using System;, which made C# take the Subscribe method from another lib. this.WhenAnyValue(activity => activity.ViewModel.WeatherIcon) .Subscribe(image => { if (image == null) return; WeatherImageView.SetImageDrawable(image.ToNative());...

Filter IObservable with regex and return matched value

c#,system.reactive,reactiveui

I think you may be over-thinking it. Everything you've suggested sounds reasonable and would result in easy to follow code in the first instance. You can wrap the regex projection+filtering logic into a custom operator with a meaningful name to maximise readability. Check if performance is a problem before you...

Reactive UI how to use WhenAny using two properties?

.net,wpf,reactiveui

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.Value) .Where(_ => Identifier == "xyz") .Subscribe(_ => { isOk = true; }); Is this what you wanted? PS.: I should have asked this in...

How to select the listbox items from View Model

c#,windows-phone-7,mvvm,listbox,reactiveui

In xaml in ListBox: SelectedItem={Binding SelectedStudent, Mode=TwoWay} Then in ViewModel: public ObservableCollection<YOUR_OBJECT_HERE> SelectedItems { get; set;} EDIT Full example: <ListBox Margin="5,0" Grid.Row="1" Grid.RowSpan="2" ItemsSource="{Binding Roles}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}"> <ListBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Path=Title}" /> </DataTemplate> </ListBox.ItemTemplate> </ListBox> ViewModel public class RolesViewModel :...

ReactiveUI exception handle recovery for ReactiveCommand.CreateAsyncTask

reactiveui

the called method signature that I was using was causing the issue. private Task<Unit> DeleteImpl() { throw new NotImplementedException(); } was missing the async keyword changing the method to private async Task<Unit> DeleteImpl() { throw new NotImplementedException(); } ...

meteor piechart doesn't show up completely

javascript,mongodb,d3.js,meteor,reactiveui

Thank you all.... No need of any corrections to the code. I got it worked by changing the _id of the documents. I gave my own _id instead of the auto generated _ids in mongoldb

TestScheduler not working like expected on subscribed property (w throttle)

c#,system.reactive,reactive-programming,reactiveui

Throttle doesn't set the scheduler, write Throttle(timespan, RxApp.MainThreadScheduler) instead

ReactiveUI & User Prompts

reactiveui

The UserError framework would work well for this scenario, it's probably what I would do. The advantage of using UserError is that you can simulate all of the scenarios really easily (i.e. user declines first view, decides yes later; user clicks yes; etc etc). Define a subclass of UserError (LocationPermissionError...

Observe for ItemChanged on two ReactiveLists

c#,reactiveui

The first won't work as it's observing property changes and ItemChanged itself won't change, it's an observable. The second is pretty much correct, but requires a bit of a modification. WhenAnyObservable requires that all the observables are the same type. As you're uninterested in the actual result, you can select...

Xamarin Form Reactive UI MasterDetailPage

xamarin.forms,reactiveui

Not at the moment - you can certainly use ReactiveUI without routing though, it's an entirely optional feature

Cancellation of async Task in ReactiveUI ViewModel (ReactiveObject)

c#,mvvm,reactiveui,cancellation

RxUI 5.x doesn't have this built-in, but it's easy to fake: var results = searchCommand.RegisterAsync<List<Location>>( _ => Observable.StartAsync(ct => DoSearchAsync(query, ct))); In RxUI v6, this is built in: searchCommand = ReactiveCommand.CreateAsyncTask( (_, ct) => DoSearchAsync(query, ct)); ...

ReactiveUI Testing

reactiveui

Your Throttle doesn't set a scheduler, this is a classic TestScheduler mistake

CSLA/ReactiveUI serialization issue

wpf,system.reactive,reactiveui,csla

It appears that this is a bug in ReactiveUI. If their type isn't actually serializable and isn't designed to flow across AppDomain, process, or network boundaries, then it shouldn't be marked as serializable.

ReactiveList.AddRange not working for large collections

c#,reactiveui,akavache

Looks like this issue was fixed in ReactiveUI 6.2.1.

Setting up ReactiveUI.Mobile

mvvm,routing,windows-runtime,reactiveui

It states that by setting up ReactiveUI.Mobile, you will be able to achieve correct handling of the back button for free. I've tried to look around for documentation but can't seem to find any. Setting up RxUI.Mobile is super platform-dependent, and you only get a free back button on...

Compound Output Properties in ReactiveUI

c#,reactiveui

Try the following: this.WhenAnyValue (x => x.Month, y => y.Year ) .Select (x => String.Format("{0} {1}", CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName (x.Item1), x.Item2)) .ToProperty (this, x => x.DateLabel, out dateLabel); I think that will do what you want!...

What is the correct way to subscribe to ReactiveCommand in RxUI 6?

c#,xamarin-studio,reactiveui

This code is perfect, i think you're just missing a using statement, "using System.Reactive" Update: The reason that this doesn't work is code that's not in the snippet. You declared TryAuthenticateCommand as IReactiveCommand which doesn't implement IObservable<T> (what would T be?). In this case, since you're not providing an async...

How do I register an IBindingTypeConverter in ReactiveUI

reactiveui

The way to do it is via Splat's service locator: Locator.CurrentMutable.RegisterConstant( new MyCoolTypeConverter(), typeof(IBindingTypeConverter)); Update: If you're using RxUI 5.x, it's "RxApp.CurrentMutable"...

How do I combine these two commands into one?

c#,wpf,system.reactive,reactiveui

This API is actually intentionally missing, because there is no elegant way for Create to return both the ReactiveCommand and the IDisposable result from Create. You could do something ugly with out parameters, but it'd end up being pretty cumbersome. While I definitely also sometimes miss a CreateWithAction or something...

ReactiveUI ToProperty exceptions

c#,system.reactive,reactiveui

The reason you're seeing these exceptions is because you're using WhenActivated in the ViewModel, and those VMs are being removed before the Task completes. You don't need to use WhenActivated in the ViewModel unless: You need to know when the View associated with this ViewModel actually becomes visible or is...

Moving from RelayCommand to ReactiveCommand

reactiveui,relaycommand

How about this: var canExecute = this.WhenAny(x => x.kvartal.KanGodkendeBilag, x => x.IsBusy, (bilag, busy) => bilag.Value && !busy.Value); GodkendeBilagCommand = ReactiveCommand.Create(canExecute); ...

The correct way to raise propertychanged in ReactiveUI

mvvm,reactiveui

In ReactiveUI, the desire to do this means that you are Doing It Wrong (or at least, not the RxUI way). IsSaveable is related to IsValid, you should describe that using WhenAny and ToProperty. Maybe you could write that as: this.WhenAny(x => x.IsValid, x => x.IsChanged, (valid, changed) => valid.Value...

Displaying progress of processing collection

c#,system.reactive,reactiveui

It seems a bit confusing because of all the parallel patterns are mixed together here: I would suggest something more like (untested): Command = ReactiveCommand.CreateAsyncObservable(_ => { return items.ToObservable() .SelectMany(RunSlowProcess, (item, itemIndex, processed) => itemIndex); }) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(i => Progress = i); ...

Threading argument through observable sequence

c#,system.reactive,reactiveui

I think this is what you're after: (from progressController in Dialogs.ShowProgress("logging in", "doing stuff...") from result in DoTheActualLogin(pair) select new { result, progressController }) .Subscribe(anon => {...}, ex => {...}) ...