本文整理汇总了C#中ReactiveCommand.InvokeCommand方法的典型用法代码示例。如果您正苦于以下问题:C# ReactiveCommand.InvokeCommand方法的具体用法?C# ReactiveCommand.InvokeCommand怎么用?C# ReactiveCommand.InvokeCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReactiveCommand
的用法示例。
在下文中一共展示了ReactiveCommand.InvokeCommand方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SearchViewModel
public SearchViewModel(IScreen hostScreen, ILoginMethods loginMethods)
{
HostScreen = hostScreen;
SearchResults = new ReactiveCollection<ISongTileViewModel>();
var playApi = loginMethods.CurrentAuthenticatedClient;
if (playApi == null) {
hostScreen.Router.Navigate.Execute(RxApp.GetService<IWelcomeViewModel>());
return;
}
var canSearch = this.WhenAny(x => x.SearchQuery, x => !String.IsNullOrWhiteSpace(x.Value));
PerformSearch = new ReactiveAsyncCommand(canSearch);
this.ObservableForProperty(x => x.SearchQuery)
.Throttle(TimeSpan.FromMilliseconds(700), RxApp.DeferredScheduler)
.InvokeCommand(PerformSearch);
var searchResults = PerformSearch.RegisterAsyncObservable(_ => playApi.Search(SearchQuery));
SearchResults = searchResults
.Do(_ => SearchResults.Clear())
.SelectMany(list => list.ToObservable())
.LoggedCatch(this, Observable.Empty<Song>())
.CreateCollection(x => (ISongTileViewModel) new SongTileViewModel(x, playApi));
PerformSearch.ItemsInflight.StartWith(0)
.Select(x => x > 0 ? Visibility.Visible : Visibility.Collapsed)
.ToProperty(this, x => x.SearchBusySpinner);
PerformSearch.ThrownExceptions.Subscribe(_ => { });
GoBack = new ReactiveCommand();
GoBack.InvokeCommand(hostScreen.Router.NavigateBack);
}