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

Filters and Transformations with Observables

The following program will help us to understand how filter and map Operators work, besides the usual mechanism of connecting an Observer to Observable Streams ,using the subscribe method. The filter method evaluates a predicate on each item of the Stream, and if the evaluation happens to produce a positive assertion, the item will be present in the output Stream. The map operator applies a lambda expression on each element of its input Stream and helps produce an output value every time (which can be propagated through the pipeline):

/////////////////////////////////////// // Second.cpp #include "rxcpp/rx.hpp" #include <ioStream> int main() { auto values = rxcpp::observable<>::range(1, 12). filter([](int ...
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