Skip to content

Instantly share code, notes, and snippets.

@vinsguru
Created October 25, 2020 16:45
Show Gist options
  • Save vinsguru/9217c4775eaca047b74d76d0d8610710 to your computer and use it in GitHub Desktop.
Save vinsguru/9217c4775eaca047b74d76d0d8610710 to your computer and use it in GitHub Desktop.
//our NetFlux streamer
//each scene will play for 2 seconds
Flux<String> netFlux = Flux.fromStream(() -> getMovie())
.delayElements(Duration.ofSeconds(2));
// you start watching the movie
netFlux.subscribe(scene -> System.out.println("You are watching " + scene));
//I join after sometime
Thread.sleep(5000);
netFlux.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