Created
September 6, 2013 15:03
-
-
Save kirkshoop/6465077 to your computer and use it in GitHub Desktop.
Sync subscription to ReactiveCommand that subscribes to accelerometer readings and displays them.
This file contains 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
// enable the scenario when enable is executed | |
from(observable(enable)) | |
.where([this](RoutedEventPattern) | |
{ | |
return accelerometer != nullptr; | |
}) | |
.select_many([=](RoutedEventPattern) | |
{ | |
return from(visible) | |
.select_many([=](bool) | |
{ | |
// enable sensor input | |
return rx::from(readingChanged) | |
.take_until(invisible); | |
}) | |
.take_until(endScenario); // this is a subscription to the disable ReactiveCommand | |
}) | |
.subscribe([this](AccelerometerReading^ reading) | |
{ | |
// on the ui thread | |
this->ScenarioOutput_X->Text = reading->AccelerationX.ToString(); | |
this->ScenarioOutput_Y->Text = reading->AccelerationY.ToString(); | |
this->ScenarioOutput_Z->Text = reading->AccelerationZ.ToString(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment