Skip to content

Instantly share code, notes, and snippets.

@shazin
Last active December 9, 2017 05:27
Show Gist options
  • Save shazin/82059f6661edefdc12aef569e9cf709d to your computer and use it in GitHub Desktop.
Save shazin/82059f6661edefdc12aef569e9cf709d to your computer and use it in GitHub Desktop.
// Find All, Subscribe, Be Active until disposed or completed.
Disposable subscription = taxiRepository.findWithTailableCursorBy()
.doOnNext(System.out::println)
.doOnComplete(() -> System.out.println("Finished"))
.doOnTerminate(() -> System.out.println("Terminated"))
.subscribe();
Thread.sleep(1000);
taxiRepository.save(new Taxi(UUID.randomUUID().toString(), "ABC-1234", 4)).subscribe();
Thread.sleep(100);
taxiRepository.save(new Taxi(UUID.randomUUID().toString(), "XYZ-1234", 4)).subscribe();
Thread.sleep(1000);
subscription.dispose();
taxiRepository.save(new Taxi(UUID.randomUUID().toString(), "DEF-1234", 4)).subscribe();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment