本文整理汇总了C#中ReactiveCommand.ObserveOn方法的典型用法代码示例。如果您正苦于以下问题:C# ReactiveCommand.ObserveOn方法的具体用法?C# ReactiveCommand.ObserveOn怎么用?C# ReactiveCommand.ObserveOn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReactiveCommand
的用法示例。
在下文中一共展示了ReactiveCommand.ObserveOn方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectedToolViewModel
public SelectedToolViewModel(UIView toolboxView, AvailableToolsContainerViewController container, MeetingViewModel meeting, IReactiveList<IToolViewModel> selectedTools, NavigationPaneViewModel navigationPane)
{
SelectedTools = selectedTools;
IsEmpty = SelectedTools.Count == 0;
SelectedTools.Changed.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(p =>
{
IsEmpty = SelectedTools.Count == 0;
});
var showAvailableToolsCommand = new ReactiveCommand();
showAvailableToolsCommand.ObserveOn(RxApp.MainThreadScheduler).Subscribe(_ =>
{
UIView.BeginAnimations(null);
UIView.SetAnimationDuration(0.25);
toolboxView.Alpha = 1.0f;
UIView.CommitAnimations();
});
container.CloseToolboxRequested += (s, e) =>
{
UIView.BeginAnimations(null);
UIView.SetAnimationDuration(0.25);
toolboxView.Alpha = 0.0f;
UIView.CommitAnimations();
};
ShowAvailableToolsCommand = showAvailableToolsCommand;
navigationPane.ShowToolLibraryAction = () => ShowAvailableToolsCommand.Execute(null);
var setActiveToolsCommand = new ReactiveCommand();
setActiveToolsCommand.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(tool => meeting.ActiveTool = (IToolViewModel)tool);
SetActiveToolCommand = setActiveToolsCommand;
}
示例2: DispatchViewModel
public DispatchViewModel(IScreen screen, ISession session)
{
HostScreen = screen;
GoBack = HostScreen.Router.NavigateBack;
Techs = new ReactiveList<Employee>();
Tickets = new ReactiveList<Ticket>();
var getFreshTechs = new ReactiveCommand();
getFreshTechs.ObserveOn(RxApp.MainThreadScheduler).Subscribe(_ =>
{
Techs.Clear();
session.FetchResults<Employee>()
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(x => Techs.Add(x));
});
var getFreshTickets = new ReactiveCommand();
getFreshTickets.ObserveOn(RxApp.MainThreadScheduler).Subscribe(_ =>
{
Tickets.Clear();
session.FetchResults<Ticket>()
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(x => Tickets.Add(x));
});
Refresh = new ReactiveCommand(session.IsWorking.Select(x => !x));
Refresh.Subscribe(_ =>
{
getFreshTechs.Execute(default(object));
getFreshTickets.Execute(default(object));
});
Assign = new ReactiveCommand(Observable.CombineLatest(
this.WhenAny(
x => x.SelectedEmployee,
y => y.SelectedTicket,
(x, y) => x.Value != null && y.Value != null),
Refresh.CanExecuteObservable,
(x, y) => x && y));
Assign.Subscribe(_ =>
{
using (session.ScopedChanges())
{
var eventTaker = session.Take<TicketEvent>();
eventTaker.Add(new TicketEvent { Employee = SelectedEmployee, Ticket = SelectedTicket, TicketStatus = TicketStatus.Assigned, Time = DateTime.Now });
}
});
_error = session.ThrownExceptions
.Select(x => x.Message)
.ObserveOn(RxApp.MainThreadScheduler)
.ToProperty(this, x => x.Error);
Refresh.Execute(default(object));
}
示例3: NavigationPaneViewModel
public NavigationPaneViewModel(INavigationService navigation)
{
IsToolLibraryButtonHidden = true;
IsUpcomingMeetingsButtonHidden = true;
var invokeToolLibraryCommand = new ReactiveCommand(this.WhenAnyValue(p => p.IsToolLibraryButtonHidden, p => !p));
invokeToolLibraryCommand.ObserveOn(RxApp.MainThreadScheduler).Subscribe(p =>
{
if (ShowToolLibraryAction != null && !IsToolLibraryButtonHidden)
{
HideNavPaneCommand.Execute(null);
ShowToolLibraryAction();
}
});
InvokeToolLibraryCommand = invokeToolLibraryCommand;
var invokeUpcomingMeetingsCommand = new ReactiveCommand(this.WhenAnyValue(p => p.IsUpcomingMeetingsButtonHidden, p => !p));
invokeUpcomingMeetingsCommand.ObserveOn(RxApp.MainThreadScheduler).Subscribe(p =>
{
if (!IsUpcomingMeetingsButtonHidden)
{
HideNavPaneCommand.Execute(null);
navigation.BackCommand.Execute(null);
}
});
InvokeUpcomingMeetingsCommand = invokeUpcomingMeetingsCommand;
var showSettingsCommand = new ReactiveCommand();
//showSettingsCommand.RegisterAsync(async p =>
//{
//});
ShowSettingsCommand = showSettingsCommand;
var showPrivacyPolicyCommand = new ReactiveCommand();
//showPrivacyPolicyCommand.RegisterAsync(async p =>
//{
//});
ShowPrivacyPolicyCommand = showPrivacyPolicyCommand;
var hideNavPaneCommand = new ReactiveCommand();
hideNavPaneCommand.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(p =>
{
if (HideNavPaneAction != null) HideNavPaneAction();
});
HideNavPaneCommand = hideNavPaneCommand;
var logoutCommand = new ReactiveCommand();
logoutCommand.ObserveOn(RxApp.MainThreadScheduler).Subscribe(p => navigation.PopToRoot());
LogoutCommand = logoutCommand;
}
示例4: DemoViewModel
public DemoViewModel([CanBeNull] IEnumerable<IElevationProvider> providers = null)
{
_availableElevationProviders = providers ?? Locator.Current.GetService<IEnumerable<IElevationProvider>>();
if (_availableElevationProviders == null) throw new ArgumentNullException("providers");
_writeableBitmap = new WriteableBitmap(pixelWidthInt, pixelHeightInt, 96, 96, PixelFormats.Rgb24, null);
var epAvailable = this.WhenAnyValue(t => t.SelectedElevationProvider)
.Select(sep => sep != null);
_retrieveElevationsCommand = ReactiveCommand.CreateAsyncTask(epAvailable, _ => refreshElevationsAsync());
_retrieveElevationsCommand.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(s => ElevationValueStats = s);
_retrieveElevationsCommand.ThrownExceptions.Subscribe(e => UserError.Throw("Error during retrieval of elevation data", e));
_selectedElevationProvider = _availableElevationProviders.FirstOrDefault();
_progress = _progresSubject.ToProperty(this, t => t.Progress, scheduler: RxApp.MainThreadScheduler);
}
示例5: AnnotationToolViewModel
public AnnotationToolViewModel(AgentAnnotationViewModel agentAnnotations)
{
AgentAnnotations = agentAnnotations;
_isEditingSub = AgentAnnotations.WhenAnyValue(p => p.IsEditing, p => p).Where(p => !p).Subscribe(_ => ClearAllActive());
_activeToolSub = this.WhenAnyValue(p => p.RectActive, p => p.EllipseActive, p => p.FreeDrawActive, p => p.LineActive,
(a, b, c, d) =>
{
return !a && !b && !c && !d;
}).Where(p => p).Subscribe(_ =>
{
Type = null;
});
_undoCommand = new ReactiveCommand(
agentAnnotations.WhenAny(p => p.ContainsAnnotationsForCurrentPage, p => p.Value).Select(p => p));
_undoCommand.ObserveOn(RxApp.MainThreadScheduler).Subscribe(p =>
{
ClearAllActive();
agentAnnotations.UndoAnnotation();
});
_rectCommand = new ReactiveCommand();
_rectCommand.ObserveOn(RxApp.MainThreadScheduler).Subscribe(p =>
{
ClearAllActive();
RectActive = true;
Type = AnnotationType.Rectangle;
});
_ellipseCommand = new ReactiveCommand();
_ellipseCommand.ObserveOn(RxApp.MainThreadScheduler).Subscribe(p =>
{
ClearAllActive();
EllipseActive = true;
Type = AnnotationType.Ellipse;
});
_lineCommand = new ReactiveCommand();
_lineCommand.ObserveOn(RxApp.MainThreadScheduler).Subscribe(p =>
{
ClearAllActive();
LineActive = true;
Type = AnnotationType.Line;
});
_freeDrawCommand = new ReactiveCommand();
_freeDrawCommand.ObserveOn(RxApp.MainThreadScheduler).Subscribe(p =>
{
ClearAllActive();
FreeDrawActive = true;
Type = AnnotationType.AdHoc;
});
}