I bet you didn't know ReactiveUI provides code snippets to make working with common parts of the framework easier. If you are unfamiliar with snippets, you can read more about it on Visual Studio or JetBrains Rider documentation. In support of Louis Matos’s Xamarin Month, focused on Code Snippets, here is some information on what ReactiveUI provides.
ReactiveUI has a good amount of documentation. Our website has everything from API documentation for the various libraries we support, to documentation on how to affect various features of the framework. We even have a getting started guide for installing snippets into your IDE.
We are an equal opportunity project. We support several of the major IDE's available in the .NET development space.
ReactiveUI provides coded bindings. These exist primarily for frameworks that don't use XAML as a basis for UI generation but can be used on XAML pages as well in the code file containing the partial class (.xaml.cs). ReactiveUI provides a strongly typed BindingContext
called ViewModel
. This allows us to have fidelity into properties for binding. You can use the non-typed, be prepared to cast the BindingContext
in that case.
this.OneWayBind(ViewModel, viewModel => viewModel.IsLoading, view => view.Loading.IsVisible);
this.Bind(ViewModel, viewModel => viewModel.SearchText, view => view.SearchBar.Text);
this.BindCommand(ViewModel, viewModel => viewModel.ClickedCommand, view => view.Button, nameof(Button.Clicked));
ReactiveUI has Fody Property Change. If you aren't a fan of IL weaving, these next snippets are for you! They provide properties that surface INotifyPropertyChanged
events for ReactiveObjects
, the base of INPC
for ReactiveUI.
private Guid _id;
. . .
public Guid Id
{
get => _id;
set => this.RaiseAndSetIfChanged(ref _id, value);
}
private ObservableAsPropertyHelper<bool> _result;
public bool Result => _result.Value;
public ReactiveCommand<Unit, Unit> NavigateCommand { get; }
Interactions are their own thing. They exist to allow you to invert control flow. When you are in ViewModel logic and need to get information from the user, Interactions provides a truly decoupled (not with some odd abstraction) approach for you to capture it. They are unit-testable by default, and I have not missed the inclusion of a dialog service being injected everywhere. If you want to see them in action I recently did a Live Stream on the topic.
public Interaction<Exception, bool> ShowException = new Interaction<Exception, bool>();
There are a few more snippets that I don't find as much value in, but they exist. I recently started adopting DynamicData. The author did not provide snippets but did provide code to show what you might want from a snippet. Who knows, maybe in my abundance of spare time, I might see if making some DynamicData snippets is in order.
comments powered by Disqus