Skip to content

Instantly share code, notes, and snippets.

@vinsguru
Created October 25, 2020 16:46
Show Gist options
  • Save vinsguru/41096b159f037dcaa117a104c7b75e29 to your computer and use it in GitHub Desktop.
Save vinsguru/41096b159f037dcaa117a104c7b75e29 to your computer and use it in GitHub Desktop.
//our movie theatre
//each scene will play for 2 seconds
Flux<String> movieTheatre = Flux.fromStream(() -> getMovie())
.delayElements(Duration.ofSeconds(2))
.share();
// you start watching the movie
movieTheatre.subscribe(scene -> System.out.println("You are watching " + scene));
//I join after sometime
Thread.sleep(5000);
movieTheatre.subscribe(scene -> System.out.println("Vinsguru is watching " + scene));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment