ReactivePlusPlus
ReactiveX implementation for C++20
Loading...
Searching...
No Matches
multicast.cpp
#include <rpp/rpp.hpp>
#include <iostream>
int main() // NOLINT(bugprone-exception-escape)
{
{
auto observable = rpp::source::just(1, 2, 3) | rpp::operators::multicast(subject);
observable.subscribe([](int v) { std::cout << "#1 " << v << std::endl; });
observable.subscribe([](int v) { std::cout << "#2 " << v << std::endl; });
observable.connect();
// Output:
// #1 1
// #2 1
// #1 2
// #2 2
// #1 3
// #2 3
}
{
observable.subscribe([](int v) { std::cout << "#1 " << v << std::endl; });
observable.subscribe([](int v) { std::cout << "#2 " << v << std::endl; });
observable.connect();
// Output:
// #1 1
// #2 1
// #1 2
// #2 2
// #1 3
// #2 3
}
{
auto observable = rpp::source::just(1, 2, 3) | rpp::operators::publish();
observable.subscribe([](int v) { std::cout << "#1 " << v << std::endl; });
observable.subscribe([](int v) { std::cout << "#2 " << v << std::endl; });
observable.connect();
// Output:
// #1 1
// #2 1
// #1 2
// #2 2
// #1 3
// #2 3
}
return 0;
}
Subject which just multicasts values to observers subscribed on it. It contains two parts: observer a...
Definition publish_subject.hpp:81
auto publish()
Converts ordinary observable to rpp::connectable_observable with help of inline instsantiated publish...
Definition publish.hpp:22
auto multicast()
Converts ordinary observable to rpp::connectable_observable with help of inline instsantiated subject...
Definition multicast.hpp:85
auto just(const TScheduler &scheduler, T &&item, Ts &&... items)
Creates rpp::observable that emits a particular items and completes.
Definition from.hpp:201