This file contains 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
var canSearch = this.WhenAnyValue(vm => vm.SearchTerm) | |
.Where(x => !string.IsNullOrWhiteSpace(x) && x.Length >= 3) | |
.Publish() | |
.RefCount(); | |
SearchCmd = ReactiveCommand.CreateFromObservable<string, IEnumerable<string>>(term => Observable.StartAsync(_ => _movieService.GetMovies(term)).TakeUntil(canSearch)); | |
SearchCmd.Subscribe(results => | |
{ | |
Results.Clear(); |
This file contains 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
_isSearching = SearchCmd.IsExecuting.ToProperty(this, vm => vm.IsSearching); |
This file contains 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
readonly ObservableAsPropertyHelper<bool> _isSearching; | |
public bool IsSearching => _isSearching.Value; |
This file contains 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
public ReactiveCommand<string, IEnumerable<string>> SearchCmd { get; set; } | |
public ReactiveList<string> Results { get; set; } | |
string _searchTerm; | |
public string SearchTerm | |
{ | |
get { return _searchTerm; } | |
set { this.RaiseAndSetIfChanged(ref _searchTerm, value); } | |
} |
This file contains 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
Results = new ReactiveList<string>(); | |
var canSearch = this.WhenAny(x => x.SearchTerm, x => !string.IsNullOrWhiteSpace(x.Value) && x.Value.Length >= 3); | |
SearchCmd = ReactiveCommand.CreateFromTask<string, IEnumerable<string>>(term => _movieService.GetMovies(term), canSearch); | |
SearchCmd.Subscribe(results => | |
{ | |
Results.Clear(); | |
Results.AddRange(results); | |
}); |
This file contains 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
public partial class MainPage : ContentPage, IViewFor<MainViewModel> | |
{ | |
public MainPage() | |
{ | |
InitializeComponent(); | |
ViewModel = new MainViewModel(new MovieService()); | |
this.Bind(ViewModel, vm => vm.SearchTerm, v => v.entryField.Text); | |
this.OneWayBind(ViewModel, vm => vm.Results, v => v.resultList.ItemsSource); | |
this.OneWayBind(ViewModel, vm => vm.IsSearching, v => v.loadingBar.IsVisible); | |
} |
This file contains 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
<?xml version="1.0" encoding="utf-8" ?> | |
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" | |
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | |
xmlns:local="clr-namespace:ReactiveUIExampleXamarinForms" | |
x:Class="ReactiveUIExampleXamarinForms.MainPage"> | |
<StackLayout Padding="12"> | |
<Label Text="Search:" VerticalOptions="Center" HorizontalOptions="Center" /> | |
<Entry x:Name="entryField" /> | |
<ActivityIndicator x:Name="loadingBar"/> |
This file contains 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
await _dialogService.ShowMessage("Message, "Title", "Ok", AfterAction); |
This file contains 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
public RelayCommand AddMonthCmd => new RelayCommand(async () => | |
{ | |
// w DashboardViewModel | |
await _navigationService.Navigate<MonthEditPage>(); | |
}); | |
public RelayCommand SaveCmd => new RelayCommand(async () => | |
{ | |
// w MonthEditViewModel - wracamy do Dashboardu | |
// zapisujemy... |
This file contains 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
public class DashboardViewModel : ViewModelBase | |
{ | |
IDbService _dbService; | |
INavigationService _navigationService; | |
IMonthService _monthService; | |
public DashboardViewModel(IDbService dbService, INavigationService navigationService, IMonthService monthService) | |
{ | |
_dbService = dbService; | |
_navigationService = navigationService; |