Skip to content

Instantly share code, notes, and snippets.

@jwkidd3
Created January 18, 2017 22:11
Show Gist options
  • Save jwkidd3/c9a56f8ea764b87e3b47bfda15805dd4 to your computer and use it in GitHub Desktop.
Save jwkidd3/c9a56f8ea764b87e3b47bfda15805dd4 to your computer and use it in GitHub Desktop.
ConnectableObservable<Long> cold = Observable.interval(200, TimeUnit.MILLISECONDS).replay();
Subscription s = cold.connect();
System.out.println("Subscribe first");
Subscription s1 = cold.subscribe(i -> System.out.println("First: " + i));
Thread.sleep(700);
System.out.println("Subscribe second");
Subscription s2 = cold.subscribe(i -> System.out.println("Second: " + i));
Thread.sleep(500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment