Skip to content

Instantly share code, notes, and snippets.

@akarnokd
Created February 6, 2020 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akarnokd/a88d2d6c46433302498412e6c1a605fe to your computer and use it in GitHub Desktop.
Save akarnokd/a88d2d6c46433302498412e6c1a605fe to your computer and use it in GitHub Desktop.
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