Last active
January 25, 2021 20:20
-
-
Save rdelrosario/057c1aabbb29413d071f79242889234b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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