Created
October 22, 2017 18:56
-
-
Save tomwis/6d9690c5152f4849eaebcc94ff6f6bb8 to your computer and use it in GitHub Desktop.
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(); | |
Results.AddRange(results); | |
}); | |
canSearch | |
.Throttle(TimeSpan.FromMilliseconds(500)) | |
.InvokeCommand(SearchCmd); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment