Created
February 6, 2020 09:33
-
-
Save akarnokd/a88d2d6c46433302498412e6c1a605fe to your computer and use it in GitHub Desktop.
This file contains 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
package hu.akarnokd.rxjava2; | |
import java.util.concurrent.TimeUnit; | |
import org.junit.Test; | |
import io.reactivex.*; | |
public class ObsMergeWithCompTest { | |
@Test | |
public void test() throws Exception { | |
Completable c = Completable.create(emitter -> new Thread(() -> { | |
System.out.println("Completable start"); | |
try { | |
Thread.sleep(1000); | |
emitter.onComplete(); | |
} catch (Throwable ex) { | |
ex.printStackTrace(); | |
} | |
}).start()); | |
Observable.just(1).delay(500, TimeUnit.MILLISECONDS) | |
.mergeWith(c) | |
.subscribe(System.out::println, Throwable::printStackTrace, () -> System.out.println("Done")); | |
// Thread.sleep(2000); | |
} | |
public static void main(String[] args) { | |
Completable c = Completable.create(emitter -> new Thread(() -> { | |
System.out.println("Completable start"); | |
try { | |
Thread.sleep(1000); | |
emitter.onComplete(); | |
} catch (Throwable ex) { | |
ex.printStackTrace(); | |
} | |
}).start()); | |
Observable.just(1).delay(500, TimeUnit.MILLISECONDS) | |
.mergeWith(c) | |
.subscribe(System.out::println, Throwable::printStackTrace, () -> System.out.println("Done")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment