本文整理汇总了C#中ReplaySubject.CombineLatest方法的典型用法代码示例。如果您正苦于以下问题:C# ReplaySubject.CombineLatest方法的具体用法?C# ReplaySubject.CombineLatest怎么用?C# ReplaySubject.CombineLatest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReplaySubject
的用法示例。
在下文中一共展示了ReplaySubject.CombineLatest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SettingsViewModel
public SettingsViewModel(IBiometricsService biometricsService, IApplicationStateService applicationStateService, IBandService bandService, IShell shell)
{
Guard.NotNull(biometricsService, nameof(biometricsService));
Guard.NotNull(applicationStateService, nameof(applicationStateService));
Guard.NotNull(bandService, nameof(bandService));
this._biometricsService = biometricsService;
this._applicationStateService = applicationStateService;
this._bandService = bandService;
this._shell = shell;
var hasUser = new ReplaySubject<bool>(1);
hasUser.OnNext(this._applicationStateService.GetCurrentUser() != null);
var deviceAvailable = this._biometricsService.BiometricAuthDeviceIsAvailableAsync().ToObservable();
var canRememberLogin = hasUser.CombineLatest(deviceAvailable, (hasUsr, deviceAvail) => hasUsr && deviceAvail);
this.RememberLogin = UwCoreCommand.Create(canRememberLogin, this.RememberLoginImpl)
.ShowLoadingOverlay(CTime2Resources.Get("Loading.RememberedLogin"))
.HandleExceptions()
.TrackEvent("SetupRememberLogin");
var canToggleTile = this.WhenAnyValue(f => f.State, state => state != BandState.NotConnected);
this.ToggleBandTile = UwCoreCommand.Create(canToggleTile, this.ToggleTileImpl)
.ShowLoadingOverlay(() => this.State == BandState.Installed
? CTime2Resources.Get("Loading.RemoveTileFromBand")
: CTime2Resources.Get("Loading.AddTileToBand"))
.HandleExceptions()
.TrackEvent("ToggleBandTile");
this.Reload = UwCoreCommand.Create(this.ReloadImpl)
.ShowLoadingOverlay(CTime2Resources.Get("Loading.Settings"))
.HandleExceptions()
.TrackEvent("ReloadSettings");
this.Theme = this._applicationStateService.GetApplicationTheme();
this.SelectedWorkTime = this._applicationStateService.GetWorkDayHours();
this.SelectedBreakTime = this._applicationStateService.GetWorkDayBreak();
this.CompanyId = this._applicationStateService.GetCompanyId();
this.WhenAnyValue(f => f.Theme)
.Subscribe(theme =>
{
this._shell.Theme = theme;
this._applicationStateService.SetApplicationTheme(theme);
});
this.WhenAnyValue(f => f.SelectedWorkTime)
.Subscribe(workTime =>
{
this._applicationStateService.SetWorkDayHours(workTime);
});
this.WhenAnyValue(f => f.SelectedBreakTime)
.Subscribe(breakTime =>
{
this._applicationStateService.SetWorkDayBreak(breakTime);
});
this.WhenAnyValue(f => f.CompanyId)
.Subscribe(companyId =>
{
this._applicationStateService.SetCompanyId(companyId);
});
this.DisplayName = CTime2Resources.Get("Navigation.Settings");
this.WorkTimes = new ReactiveList<TimeSpan>(Enumerable
.Repeat((object)null, 4 * 24)
.Select((_, i) => TimeSpan.FromHours(0.25 * i)));
this.BreakTimes = new ReactiveList<TimeSpan>(Enumerable
.Repeat((object)null, 4 * 24)
.Select((_, i) => TimeSpan.FromHours(0.25 * i)));
}