An introduction to marble diagrams for visual representation
It is difficult to visualize Rx Streams, as the data flows asynchronously. The designers of Rx systems have created a set of visualization cues called marble diagrams: Let us write a small program and depict logic of the map Operator as a marble diagram.
//------------------ Map.cpp #include "rxcpp/rx.hpp" #include "rxcpp/rx-test.hpp" #include <ioStream> #include <array> int main() { auto ints = rxcpp::observable<>::range(1,10). map( [] ( int n ) {return n*n; }); ints.subscribe( [](int v){printf("OnNext: %dn", v);}, [](){printf("OnCompletedn");}); }
Rather than giving a description of marble diagrams, let's look at a marble diagram that depicts the map
operator:
The top part of the marble diagram shows a timeline where a series of values (represented as circles) are displayed. Each of the value will be passing through a map Operator, which takes a lambda...