summaryrefslogtreecommitdiff
path: root/Rx/v2/examples/doxygen/empty.cpp
blob: 1ace4eb0eacbf74031401c3e793c0af544715aeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "rxcpp/rx.hpp"

#include "rxcpp/rx-test.hpp"
#include "catch.hpp"

SCENARIO("empty sample"){
    printf("//! [empty sample]\n");
    auto values = rxcpp::observable<>::empty<int>();
    values.
        subscribe(
            [](int v){printf("OnNext: %d\n", v);},
            [](){printf("OnCompleted\n");});
    printf("//! [empty sample]\n");
}

SCENARIO("threaded empty sample"){
    printf("//! [threaded empty sample]\n");
    auto values = rxcpp::observable<>::empty<int>(rxcpp::observe_on_event_loop());
    values.
        as_blocking().
        subscribe(
            [](int v){printf("OnNext: %d\n", v);},
            [](){printf("OnCompleted\n");});
    printf("//! [threaded empty sample]\n");
}

SCENARIO("empty operator syntax sample"){
    using namespace rxcpp::sources;

    printf("//! [empty operator syntax sample]\n");
    auto values = empty<int>();
    values.
            subscribe(
            [](int v){printf("OnNext: %d\n", v);},
            [](){printf("OnCompleted\n");});
    printf("//! [empty operator syntax sample]\n");
}