Thursday Night

Paul Betts’s personal website / blog / what-have-you

ReactiveUI 4.2 is Released!

After 5 months, 247 commits by 10 different contributors, and 634 total files changed, the stable release of ReactiveUI 4.x is now live!

Where can I see a good demo of a basic ReactiveUI 4.2 application?

A great example of ReactiveUI 4.2 in action is the sample I did for Erik Meijer and my presentation at QCon. Check out the code on GitHub – each commit is an interesting, self-contained step, and it is highly recommended that you step through commit by commit.

What does this do again?

ReactiveUI is a M-V-VM framework like MVVM Light or Caliburn.Micro, that is deeply integrated with the Reactive Extensions for .NET. This allows you to write code in your ViewModel that is far more elegant and terse when expressing complex stateful interactions, as well as much simpler handling of async operations.

What’s new?

The main thing that is new in ReactiveUI 4.x is the new View Binding support – check out the blog post about the 4.0 Preview Release to learn more about the syntax for view bindings.

Since then, the features added in the 4.1 and 4.2 releases are incremental improvments.

Async / Await everywhere

ReactiveUI now integrates the BCL Async Targeting pack in order to enable async / await support on all platforms that ReactiveUI supports, as long as you’re using VS2012, as well as porting the Rx await support. This means that you can await IObservable, as well as use await alongside ReactiveUI:

locator = new Geolocator();
getLocationCommand = new ReactiveCommand();

getLocationCommand
    .SelectMany(async x => await locator.GetGeopositionAsync())
    .ToProperty(this, x => x.CurrentPosition);

View Binding Converter support

In the initial release of ReactiveUI 4.0, view bindings had to be exact
matches in terms of types when execuiting a binding, which was frustrating to
use when trying to bind a TextBox to an Integer for example.

In ReactiveUI 4.2, View Bindings automatically support conversions between types. This feature is analagous to the IValueConverter class in XAML bindings.These converters are registered using Service Location (RxApp.Register), and custom ones can be easily registered as well. In WPF, the TypeConverter framework is used to convert between many common types.

CallerMemberName support

Along with async / await comes CallerMemberName support for RaiseAndSetIfChanged. This means that declaring read/write properties is now even cleaner:

string _Name;
public string Name {
    get { return _Name; }
    set { this.RaiseAndSetIfChanged(value); }
}

Other changes

  • Routing behavior changes – RxRouting will now attempt several common ways to map ViewModels to Views, and ViewModelToViewFunc is now properly respected (i.e. it will use exactly the view class name returned now)
  • Service location now always works, even if you don’t register a custom one. This means that small projects don’t need to reference NInject or another IoC container.
  • ReactiveCollection is now completely rewritten for performance and adds a number of new features, like being able to add ranges of values.
  • Reflection helpers that were internal methods in ReactiveUI 3.x are now exposed via a public static class called Reflection.
  • Many, many bugfixes!

Thanks!

Thanks to the following people who contributed to this release:

  • Phil Haack
  • Johan Laanstra
  • Peter Klavins
  • Cameron MacFarland
  • Wojciech BardziƄski
  • Brendan Forster
  • Jimit Ndiaye
  • John Stovin
  • Lucas Maloney
  • Rob Horvath

Written by Paul Betts

December 16th, 2012 at 8:31 pm

Posted in Uncategorized