Skip to Content
C++ Reactive Programming
book

C++ Reactive Programming

by Praseed Pai, Peter Abraham
June 2018
Intermediate to advanced
348 pages
8h 45m
English
Packt Publishing
Content preview from C++ Reactive Programming

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) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Functional Programming in C++

Functional Programming in C++

Ivan Cukic

Publisher Resources

ISBN: 9781788629775Supplemental Content