Skip to content

Instantly share code, notes, and snippets.

@tomwis
Created October 22, 2017 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomwis/42dd6b4a7acc7fa01ce4e65a3bbc788d to your computer and use it in GitHub Desktop.
Save tomwis/42dd6b4a7acc7fa01ce4e65a3bbc788d to your computer and use it in GitHub Desktop.
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.WhenAnyValue(x => x.SearchTerm)
.Throttle(TimeSpan.FromMilliseconds(500))
.InvokeCommand(SearchCmd);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment