Observers and their variants (Subscribers)
An Observer subscribes to an Observable and waits for events to be notified. Observers were already covered in the previous chapter. Hence, we will be focusing on Subscribers, which are a combination of Observers and subscriptions. A Subscriber has the facility to unsubscribe from the Observer,where as with a "vanilla" Observer, you can only subscribe. The following program explain these concepts very well:
//---- Subscriber.cpp #include "rxcpp/rx.hpp" int main() { //----- create a subscription object auto subscription = rxcpp::composite_subscription(); //----- Create a Subscription auto subscriber = rxcpp::make_subscriber<int>( subscription, [&](int v){ printf("OnNext: --%dn", v); if (v == 3) subscription.unsubscribe(); // Demonstrates Un Subscribes }, [](){ printf("OnCompletedn");}); rxcpp::observable<>::create<...