WhenAnyObservable is never having any effect on the command

43 views
Skip to first unread message

fahadash

unread,
Jan 7, 2015, 2:31:58 PM1/7/15
to reacti...@googlegroups.com
Alright this is crazy, tell me what I am doing wrong here, I have the following code (it is supposed to toggle enable/disable a command every two seconds)

           ISubject<bool> fileSystemOperationRunning = new Subject<bool>();

            var xxx =
                Observable.Interval(TimeSpan.FromSeconds(2.0)).Select(_ => true)
                    .Scan( (p, n) => !p)
                    ..CombineLatest(fileSystemOperationRunning, (a, b) => a && !b)
                .ObserveOn(RxApp.MainThreadScheduler);
            xxx.Trace("TEST1");

            var startTextAnalysis = ReactiveCommand.CreateAsyncTask(
                    xxx,
                _ => RunTextAnalysis());

            StartTextAnalysis = startTextAnalysis;
            startTextAnalysis.IsExecuting.Subscribe(fileSystemOperationRunning);

       fileSystemOperationRunning.OnNext(false);

Here is the trace output
TEST1 : True
TEST1 : False
TEST1 : True
TEST1 : False
TEST1 : True


But my Button stays disabled.
If I remove the following part, it works
                    ..CombineLatest(fileSystemOperationRunning, (a, b) => a && !b)

Why ?
Reply all
Reply to author
Forward
0 new messages