June 2018
Intermediate to advanced
348 pages
8h 45m
English
The following program shows how one can subscribe to an Observable and stop the subscription, if it is warranted. in the case of some programs ,this option is very useful. Please consult the Rxcpp documentation to understand more about the subscription and how one can use them effectively. In the mean time, following program will demonstrate how cone can un-subscribe from a Observable.
//---------------- Unsubscribe.cpp #include "rxcpp/rx.hpp" #include "rxcpp/rx-test.hpp" #include <iostream> int main() { auto subs = rxcpp::composite_subscription(); auto values = rxcpp::observable<>::range(1, 10); values.subscribe( subs,[&subs](int v){ printf("OnNext: %dn", v); if (v == 6) subs.unsubscribe(); //-- Stop ...Read now
Unlock full access