Created
September 6, 2013 05:37
-
-
Save kirkshoop/6459935 to your computer and use it in GitHub Desktop.
Reactive code to handle the suspending event and save the state.
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
auto ct = std::make_shared<rx::CurrentThreadScheduler>(); | |
typedef rxrt::EventPattern<Platform::Object^, SuspendingEventArgs^> SuspendingEventPattern; | |
rx::from(suspending) | |
.chain<rxrt::defer_operation>( | |
[](SuspendingEventPattern ep) | |
{ | |
// defer this operation | |
return ep.EventArgs()->SuspendingOperation; | |
}, | |
[](rxrt::OperationPattern<SuspendingOperation^>, SuspendingEventPattern) | |
{ | |
// do this while the operation is deferred | |
return SuspensionManager::ReactiveSave(); | |
}, | |
ct) | |
.publish() | |
.connect_forever(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment