Ejemplo n.º 1
0
    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);
        }
    }
Ejemplo n.º 2
0
 void remove(weak_subscription w) const {
     return lifetime.remove(std::move(w));
 }