本文整理汇总了C#中ReactiveProperty.Subscribe方法的典型用法代码示例。如果您正苦于以下问题:C# ReactiveProperty.Subscribe方法的具体用法?C# ReactiveProperty.Subscribe怎么用?C# ReactiveProperty.Subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReactiveProperty
的用法示例。
在下文中一共展示了ReactiveProperty.Subscribe方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NoRaiseLatestValueOnSubscribe
public void NoRaiseLatestValueOnSubscribe()
{
var rp = new ReactiveProperty<string>(mode: ReactivePropertyMode.DistinctUntilChanged);
var called = false;
rp.Subscribe(_ => called = true);
called.Is(false);
}
示例2: SettingsPageViewModel
public SettingsPageViewModel(PageManager pageManager, IReactiveFolderSettings settings)
: base(pageManager)
{
Settings = settings;
ReactionCheckInterval = new ReactiveProperty<string>(settings.DefaultMonitorIntervalSeconds.ToString());
ReactionCheckInterval.Subscribe(x =>
{
settings.DefaultMonitorIntervalSeconds = int.Parse(x);
settings.Save();
});
ReactionCheckInterval.SetValidateNotifyError(x =>
{
int temp;
if (false == int.TryParse(x, out temp))
{
return "Number Only";
}
return null;
});
}
示例3: ReactivePropertyViewModel
public ReactivePropertyViewModel()
{
FirstValue = new ReactiveProperty<double>(0.0);
SecondValue = new ReactiveProperty<double>();
Output = new ReactiveProperty<double>();
Add = new ReactiveProperty<bool>();
Substract = new ReactiveProperty<bool>();
Multiply = new ReactiveProperty<bool>();
Divide = new ReactiveProperty<bool>();
Add.Subscribe(x =>
{
if (x == true)
{
FirstValue.Subscribe(y => { Output.Value = FirstValue.Value + SecondValue.Value; });
SecondValue.Subscribe(y => { Output.Value = FirstValue.Value + SecondValue.Value; });
}
});
Substract.Subscribe(x =>
{
if (x == true)
{
FirstValue.Subscribe(y => { Output.Value = FirstValue.Value - SecondValue.Value; });
SecondValue.Subscribe(y => { Output.Value = FirstValue.Value - SecondValue.Value; });
}
});
Multiply.Subscribe(x =>
{
if (x == true)
{
FirstValue.Subscribe(y => { Output.Value = FirstValue.Value * SecondValue.Value; });
SecondValue.Subscribe(y => { Output.Value = FirstValue.Value * SecondValue.Value; });
}
});
Divide.Subscribe(x =>
{
if (x == true)
{
FirstValue.Subscribe(y => { Output.Value = FirstValue.Value / SecondValue.Value; });
SecondValue.Subscribe(y => { Output.Value = FirstValue.Value / SecondValue.Value; });
}
});
}
示例4: Initialize
protected override void Initialize()
{
var image = this.GetComponent<Image>();
Message = new ReactiveProperty<string>("");
Message.SubscribeToText(text);
Color = new ReactiveProperty<UnityEngine.Color>();
Color.Subscribe(x => image.color = x);
}
示例5: NoDistinctUntilChanged
public void NoDistinctUntilChanged()
{
var rp = new ReactiveProperty<string>(mode: ReactivePropertyMode.RaiseLatestValueOnSubscribe);
var list = new List<string>();
rp.Subscribe(list.Add);
rp.Value = "Hello world";
rp.Value = "Hello world";
rp.Value = "Hello japan";
list.Is(null, "Hello world", "Hello world", "Hello japan");
}
示例6: Character
public Character()
{
Location = new ReactiveProperty<Coord>();
Health = new ReactiveProperty<int>();
Location.Subscribe(coord =>
{
X = coord.x;
Y = coord.y;
})
.AddTo(disposables);
}
示例7: Start
void Start()
{
if (alreadyStarted) return;
alreadyStarted = true;
var image = this.GetComponent<Image>();
Message = new ReactiveProperty<string>("");
Message.SubscribeToText(text);
Color = new ReactiveProperty<UnityEngine.Color>();
Color.Subscribe(x => image.color = x);
}
示例8: Awake
void Awake()
{
Level = new ReactiveProperty<int> ();
CurrentHP = new ReactiveProperty<int> ();
MaxHP = new ReactiveProperty<int> ();
Level.Value = 1;
MaxHP.Value = 20;
CurrentHP.Value = MaxHP.Value;
Level.Subscribe (level => {
MaxHP.Value = 20 + level;
CurrentHP.Value = MaxHP.Value;
}).AddTo (this);
}
示例9: MemberViewModel
public MemberViewModel(string name, bool isSelected = false)
{
this.Name = name;
IsSelected = new ReactiveProperty<bool>(isSelected);
#region Test
IsSelectedCopy = this.ObserveProperty(x => x.IsSelectedValue);
IsSelectedCopy.Subscribe(x => Debug.WriteLine($"IsSelectedCopy {x}"));
IsSelected.Subscribe(x => IsSelectedValue = x);
#endregion
}
示例10: AppPolicyManagePageViewModel
public AppPolicyManagePageViewModel(PageManager pageManager, IAppPolicyManager appPolicyManager, IFolderReactionMonitorModel monitor)
: base(pageManager)
{
Monitor = monitor;
AppPolicyManager = appPolicyManager;
AppPolicies = AppPolicyManager.Policies
.ToReadOnlyReactiveCollection(x => new AppPolicyListItemViewModel(this, x));
SelectedAppPolicy = new ReactiveProperty<AppPolicyListItemViewModel>();
SelectedAppPolicy.Subscribe(x =>
{
if (x != null)
{
ShowAppPolicyEditPage(x.AppPolicy);
}
});
}
示例11: WipBaseFileVm
public WipBaseFileVm(Repository repos, WipFile model)
: base(true)
{
Debug.Assert(repos != null);
Debug.Assert(model != null);
_model = model;
#region IsInStaging, IsInStagingFromModel
IsInStaging = new ReactiveProperty<bool>(model.IsInStaging)
.AddTo(MultipleDisposable);
IsInStaging.Subscribe(x =>
{
if (x)
model.Stage();
else
model.Unstage();
}).AddTo(MultipleDisposable);
IsInStagingFromModel = model.ObserveProperty(x => x.IsInStaging)
.ToReadOnlyReactiveProperty()
.AddTo(MultipleDisposable);
IsInStagingFromModel
.Subscribe(x => IsInStaging.Value = x)
.AddTo(MultipleDisposable);
#endregion
if (_model.IsBinary == false)
this.MakeDiff(_model.Patch);
IsSelected = new ReactiveProperty<bool>()
.AddTo(MultipleDisposable);
DiscardChangesCommand = new ReactiveCommand()
.AddTo(MultipleDisposable);
DiscardChangesCommand
.Subscribe(_ => repos.DiscardChanges(new[] {Path}))
.AddTo(MultipleDisposable);
}
示例12: ActionsEditViewModel
public ActionsEditViewModel(FolderReactionModel reactionModel, PageManager pageManager, IAppPolicyManager appPolicyManager)
: base(pageManager, reactionModel)
{
_AppPolicyManager = appPolicyManager;
Reaction.ObserveProperty(x => x.IsActionsValid)
.Subscribe(x => IsValid.Value = x)
.AddTo(_CompositeDisposable);
// TODO: CollectionChangedをマージしてReactiveCollectionにする方法を使ってまとめる
// Note: AppLaunchActionViewModelをAppOptionValueInstance1つずつに対して作成している
Actions = new ObservableCollection<AppLaunchActionViewModel>(
Reaction.Actions.Select(
x =>
{
var appLaunchAction = x as AppLaunchReactiveAction;
return new AppLaunchActionViewModel(this, Reaction, appLaunchAction);
}
)
);
Actions.CollectionChangedAsObservable()
.Subscribe(itemPair =>
{
var onceRemoveItems = Reaction.Actions.ToArray();
foreach (var onceRemoveItem in onceRemoveItems)
{
Reaction.RemoveAction(onceRemoveItem);
}
foreach(var reAdditem in Actions)
{
Reaction.AddAction(reAdditem.Action);
}
});
IsActionsEmpty = Actions.ObserveProperty(x => x.Count)
.Select(x => x == 0)
.ToReactiveProperty();
IsActionsEmpty.Subscribe();
}
示例13: Ignore
public void Ignore()
{
var recorder = new TestScheduler().CreateObserver<Unit>();
var etr = new EventToReactive();
var rp = new ReactiveProperty<Unit>(mode: ReactivePropertyMode.None);
rp.Subscribe(recorder);
etr.ReactiveProperty = rp;
etr.IgnoreEventArgs = true;
etr.AsDynamic().Invoke((object)100);
etr.AsDynamic().Invoke((object)200);
etr.AsDynamic().Invoke((object)"hogehoge");
recorder.Messages.Is(
OnNext(0, Unit.Default),
OnNext(0, Unit.Default),
OnNext(0, Unit.Default));
}
示例14: InitialValue
public void InitialValue()
{
var rp = new ReactiveProperty<string>("Hello world");
rp.Value.Is("Hello world");
rp.Subscribe(x => x.Is("Hello world"));
}
示例15: NormalCase
public void NormalCase()
{
var rp = new ReactiveProperty<string>();
rp.Value.IsNull();
rp.Subscribe(x => x.IsNull());
}