Skip to content

Instantly share code, notes, and snippets.

@kirkshoop
Created August 31, 2013 05:35
Show Gist options
  • Save kirkshoop/6396398 to your computer and use it in GitHub Desktop.
Save kirkshoop/6396398 to your computer and use it in GitHub Desktop.
Excerpt from https://github.com/kirkshoop/rxaccelerometer showing how to create a ReactiveCommand and bind it to a Xaml button
typedef rxrt::EventPattern<Object^, Windows::UI::Xaml::RoutedEventArgs^> RoutedEventPattern;
// start out disabled
enabled = std::make_shared<rx::BehaviorSubject<bool>>(false);
// use enabled to control canExecute
disable = std::make_shared < rxrt::ReactiveCommand < RoutedEventPattern> >(observable(enabled));
from(observable(disable))
// stay on the ui thread
.subscribe([this](RoutedEventPattern)
// on click
{
...
// now the scenario is disabled
this->enabled->OnNext(false);
});
rxrt::BindCommand(ScenarioDisableButton, disable);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment