- 
      
- 
        Save KowalczykBartek/6677e60223daa6a14e15 to your computer and use it in GitHub Desktop. 
    sample of rxjava repeatWhen
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public static void main(String... args) { | |
| AtomicInteger a = new AtomicInteger(); | |
| Observable.just(1, 2, 3, 4, 5, 6, 7, 8) | |
| .repeatWhen(notification -> { | |
| return notification.flatMap(o -> { | |
| System.out.println("'repeatWhen'"); | |
| if(a.getAndAdd(1) < 10){ | |
| return Observable.just(o).delay(1,TimeUnit.SECONDS); | |
| }else{ | |
| return Observable.empty(); | |
| } | |
| }); | |
| })// | |
| .subscribe(System.out::println); | |
| while (true) ; | |
| } | 
Why should I need to put while (true) ; in the end? Isn't repeatWhen working without this?
This is to keep the program running.
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Why should I need to put
while (true) ;in the end? Isn't repeatWhen working without this?