public void TestInitialFalse()
        {
            var notifier = new BooleanNotifier(false);
            var recorder = new TestScheduler().CreateObserver<bool>();
            notifier.Subscribe(recorder);

            notifier.Value.Is(false);

            notifier.TurnOn();
            notifier.TurnOff();
            notifier.Value = true;
            notifier.Value = true;
            notifier.Value = false;
            notifier.TurnOn();
            notifier.SwitchValue();
            notifier.SwitchValue();

            recorder.Messages.Is(
                OnNext(0, true),
                OnNext(0, false),
                OnNext(0, true),
                OnNext(0, true),
                OnNext(0, false),
                OnNext(0, true),
                OnNext(0, false),
                OnNext(0, true));

            recorder.Messages.Clear();

            notifier.TurnOn();
            recorder.Messages.Count.Is(0);
        }
    public void TestInitialFalse()
    {
        var notifier = new BooleanNotifier(false);
        var recorder = new TestScheduler().CreateObserver <bool>();

        notifier.Subscribe(recorder);

        notifier.Value.Is(false);

        notifier.TurnOn();
        notifier.TurnOff();
        notifier.Value = true;
        notifier.Value = true;
        notifier.Value = false;
        notifier.TurnOn();
        notifier.SwitchValue();
        notifier.SwitchValue();

        recorder.Messages.Is(
            OnNext(0, true),
            OnNext(0, false),
            OnNext(0, true),
            OnNext(0, true),
            OnNext(0, false),
            OnNext(0, true),
            OnNext(0, false),
            OnNext(0, true));

        recorder.Messages.Clear();

        notifier.TurnOn();
        recorder.Messages.Count.Is(0);
    }
示例#3
0
        public MainWindowViewModel()
        {
            DatabaseValue = new ReactiveProperty <string>();
            InitCommand   = new ReactiveCommand <string>()
                            .WithSubscribe(isDatabaseEmpty =>
            {
                _dbValueUpdating.SwitchValue();
                using (Disposable.Create(() => _dbValueUpdating.SwitchValue()))
                {
                    DatabaseValue.Value = bool.Parse(isDatabaseEmpty) ? null : "xxxx";
                    DatabaseValue.ForceNotify();
                }
            });

            InputValue = DatabaseValue.ToReactiveProperty();

            CommandText = Observable.Merge(
                DatabaseValue.Select(x => IsDbValueEmpty(x)).Select(x => x ? "A" : "B"),
                InputValue.Where(_ => !_dbValueUpdating.Value).Select(_ => "A"))
                          .ToReadOnlyReactiveProperty();
        }
示例#4
0
 public static void SwitchValueWith(this BooleanNotifier self, Action <bool> action)
 {
     action?.Invoke(self.Value);
     self.SwitchValue();
 }
 public void OnReadyBtn()
 {
     readyNotifier.SwitchValue();
 }
 public void OnConnectBtn()
 {
     connectNotifier.SwitchValue();
 }