Application event handling example

The following example is a command-line program, with events to represent the primitive operations of a user interface application. We will be handling the flow of these events by using RxCpp in this program. This has been done for brevity in the code listing:

//--------- UI_EventsApp.cpp 
#include <rxcpp/rx.hpp> 
#include <cassert> 
#include <cctype> 
#include <clocale> 
 
namespace Rx { 
    using namespace rxcpp; 
    using namespace rxcpp::sources; 
    using namespace rxcpp::operators; 
    using namespace rxcpp::util; 
    using namespace rxcpp::subjects; 
} 
 
using namespace Rx; 
using namespace std::chrono; 
 
// Application events 
enum class AppEvent { 
    Active, 
    Inactive, 
    Data, 
    Close, 
    Finish, 
    Other 
};

The libraries and namespaces that ...

Get C++ Reactive Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.