当前位置: 首页>>代码示例>>C#>>正文


C# ReactiveProperty.Subscribe方法代码示例

本文整理汇总了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);
 }
开发者ID:ailen0ada,项目名称:ReactiveProperty,代码行数:7,代码来源:ReactivePropertyTest.cs

示例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;
			});

		}
开发者ID:tor4kichi,项目名称:ReactiveFolder,代码行数:25,代码来源:SettingsPageViewModel.cs

示例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; });
                }
            });
        }
开发者ID:SneshPrajapati,项目名称:ICommandDemo,代码行数:43,代码来源:ReactivePropertyViewModel.cs

示例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);
        }
开发者ID:ChicK00o,项目名称:UniRx,代码行数:10,代码来源:Result.cs

示例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");
 }
开发者ID:ailen0ada,项目名称:ReactiveProperty,代码行数:10,代码来源:ReactivePropertyTest.cs

示例6: Character

    public Character()
    {
        Location = new ReactiveProperty<Coord>();
        Health = new ReactiveProperty<int>();

        Location.Subscribe(coord =>
        {
            X = coord.x;
            Y = coord.y;
        })
        .AddTo(disposables);
    }
开发者ID:Mojopon,项目名称:IntoTheDeep,代码行数:12,代码来源:Character.cs

示例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);
        }
开发者ID:byfar,项目名称:UniRx,代码行数:14,代码来源:Result.cs

示例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);
    }
开发者ID:enpel,项目名称:unibook3_example,代码行数:15,代码来源:ReactiveYusya.cs

示例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
        }
开发者ID:modulexcite,项目名称:WlanProfileViewer,代码行数:15,代码来源:MemberViewModel.cs

示例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);
				}
			});
		}
开发者ID:tor4kichi,项目名称:ReactiveFolder,代码行数:17,代码来源:AppPolicyManagePageViewModel.cs

示例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);
        }
开发者ID:YoshihiroIto,项目名称:Anne,代码行数:43,代码来源:WipBaseFileVm.cs

示例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();
		}
开发者ID:tor4kichi,项目名称:ReactiveFolder,代码行数:43,代码来源:ActionsEditViewModel.cs

示例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));
        }
开发者ID:ailen0ada,项目名称:ReactiveProperty,代码行数:19,代码来源:EventToReactiveTest.cs

示例14: InitialValue

 public void InitialValue()
 {
     var rp = new ReactiveProperty<string>("Hello world");
     rp.Value.Is("Hello world");
     rp.Subscribe(x => x.Is("Hello world"));
 }
开发者ID:ailen0ada,项目名称:ReactiveProperty,代码行数:6,代码来源:ReactivePropertyTest.cs

示例15: NormalCase

 public void NormalCase()
 {
     var rp = new ReactiveProperty<string>();
     rp.Value.IsNull();
     rp.Subscribe(x => x.IsNull());
 }
开发者ID:ailen0ada,项目名称:ReactiveProperty,代码行数:6,代码来源:ReactivePropertyTest.cs


注:本文中的ReactiveProperty.Subscribe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。