Skip to content

Instantly share code, notes, and snippets.

@kirkshoop
Created September 6, 2013 15:07
Show Gist options
  • Save kirkshoop/6465139 to your computer and use it in GitHub Desktop.
Save kirkshoop/6465139 to your computer and use it in GitHub Desktop.
Creating ReactiveCommand for scenario enable and disable
// 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