Created
September 6, 2013 15:07
-
-
Save kirkshoop/6465139 to your computer and use it in GitHub Desktop.
Creating ReactiveCommand for scenario enable and disable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// start out disabled | |
auto enabled = std::make_shared<rx::BehaviorSubject<bool>>(false); | |
// start out not-working | |
auto working = std::make_shared<rx::BehaviorSubject<bool>>(false); | |
// use !enabled and !working to control canExecute | |
enable = std::make_shared < rxrt::ReactiveCommand < RoutedEventPattern> >(observable(from(enabled) | |
.combine_latest([](bool e, bool w) | |
{ | |
return !e && !w; | |
}, working))); | |
// use enabled and !working to control canExecute | |
disable = std::make_shared < rxrt::ReactiveCommand < RoutedEventPattern> >(observable(from(enabled) | |
.combine_latest([](bool e, bool w) | |
{ | |
return e && !w; | |
}, working))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment