Skip to content

Instantly share code, notes, and snippets.

@rdelrosario
Last active January 25, 2021 20:20
Show Gist options
  • Save rdelrosario/057c1aabbb29413d071f79242889234b to your computer and use it in GitHub Desktop.
Save rdelrosario/057c1aabbb29413d071f79242889234b to your computer and use it in GitHub Desktop.
namespace DynamicDataGroupingSample
{
public class MainViewModel : ReactiveObject, IDisposable
{
public MainViewModel()
{
...
//Filter logic
Func<Restaurant, bool> countryFilter(string country) => restaurant =>
{
return country == "All" || country == restaurant.Country;
};
var countryPredicate = this.WhenAnyValue(x => x.SelectedCountryFilter)
.Select(countryFilter);
_cleanUp = _sourceCache.Connect()
.RefCount()
.Filter(countryPredicate)
.Filter(filterPredicate)
.Sort(sortPredicate)
.Bind(out _restaurants)
.DisposeMany()
.Subscribe();
}
private string SortBy
{
get => _sortBy;
set => this.RaiseAndSetIfChanged(ref _sortBy, value);
}
private string _sortBy;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment