Skip to content

Commit

Permalink
Simplify the doxygen/take_until example.
Browse files Browse the repository at this point in the history
  • Loading branch information
tcw165 committed Sep 4, 2022
1 parent ca4dc0b commit 3b44431
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions src/examples/doxygen/take_until.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include <rpp/rpp.hpp>

#include <chrono>
#include <iostream>

/**
Expand All @@ -7,25 +9,15 @@
int main()
{
//! [take_until]
auto subject = rpp::subjects::publish_subject<bool>{};

rpp::source::create<int>([other_subscriber = subject.get_subscriber()](const auto& subscriber)
{
subscriber.on_next(1);
subscriber.on_next(2);

// Should see a terminate event after this
other_subscriber.on_next(true);

subscriber.on_next(3);
})
.take_until(subject.get_observable())
rpp::source::interval(std::chrono::seconds{1}, rpp::schedulers::trampoline{})
.take_until(rpp::source::interval(std::chrono::seconds{5}, rpp::schedulers::trampoline{}))
.as_blocking()
.subscribe([](int v) { std::cout << "-" << v; },
[](const std::exception_ptr&) { std::cout << "-x" << std::endl; },
[]() { std::cout << "-|" << std::endl; });
// source 1: -1-2-3-|
// source 2: ----t-
// Output : -1-2-|
// source 1: -0-1-2-3-4-5-6-7- --
// source 2: ---------0---------1- --
// Output : -0-1-2-3-|
//! [take_until]

//! [take_until terminate]
Expand Down

0 comments on commit 3b44431

Please sign in to comment.