Skip to content

Hot and Cold observables - Disconnecting: Example output is not correct. #18

Description

@huylv

Hi,
Please check the code example here:

ConnectableObservable<Long> connectable = Observable.interval(200, TimeUnit.MILLISECONDS).publish();
Subscription s = connectable.connect();

connectable.subscribe(i -> System.out.println(i));

Thread.sleep(1000);
System.out.println("Closing connection");
s.unsubscribe();

Thread.sleep(1000);
System.out.println("Reconnecting");
s = connectable.connect();

The actual output is:

0
1
2
3
4
Closing connection
Reconnecting

Notice no more values appear after Reconnecting. Looks like calling unsubscribe on the ConnectableObservable's subscription also terminates subsequent subscriptions, too. I need to call connectable.subscribe(i -> System.out.println(i)) again in order to produce output while the text says that 'old observers will begin receiving values again' after calling connect() on the ConnectableObservable object. I'm using RxJava 1.0.14.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions