observable<T> get_observable() const { auto keepAlive = s; auto observable = make_observable_dynamic<T>([=](subscriber<T> o){ if (keepAlive.get_subscription().is_subscribed()) { for (auto&& value: get_values()) o.on_next(value); } keepAlive.add(keepAlive.get_subscriber(), std::move(o)); }); return s.get_coordinator().in(observable); }
void on_connect(composite_subscription cs) { if (connection.empty()) { // the lifetime of each connect is independent auto destination = subject_value.get_subscriber(); // when the paramter is unsubscribed it should // unsubscribe the most recent connection connection.reset(cs.add(destination.get_subscription())); // when the connection is finished it should shutdown the connection destination.add(make_subscription( [cs, this](){ cs.remove(this->connection.get()); this->connection.reset(); })); source.subscribe(destination); } }
input_subscriber_type get_subscriber() const { return make_subscriber<T>(get_id(), get_subscription(), observer<T, detail::multicast_observer<T>>(*this)); }