In the tutorial we will create a sample application that uses ReactiveUI in a UWP application. what we will do is have a text field, and whenever the user types something into it, you want to make a network request which searches for that query. In bonus we will add a back off to wait for the user to stop typing before doing the request.
The idea is not mine but taken from the ReactiveUI.
First create your UWP application and add the ReactiveUI nuget package:
Either by using the command line:
Or in the Nuget package Manager:
Once installed let the fun begin!
Because we want to do a search we will have to bind a property to the textblock, first in the ViewModel of the page we will add:
Next in the XAML page we will add the SearchValue property to the AutoSuggestBox control as follow:
In our ViewModel we will need to setup the ReactiveUI events:
This means that when the SearchValue property changes and that it is not null and have more then 2 chars we will launch the OnSearchCommand() method.
We can even imagine that the search command should not be fired every time but only once the user has stopped typing for 700 milliseconds and we would have something like this:
and there you have it!