32 lines
902 B
Java
32 lines
902 B
Java
package org.mercury_im.messenger.learning_tests.rx;
|
|
|
|
import org.junit.Test;
|
|
|
|
import io.reactivex.Observable;
|
|
import io.reactivex.schedulers.Schedulers;
|
|
import io.reactivex.subjects.BehaviorSubject;
|
|
import io.reactivex.subjects.Subject;
|
|
|
|
import static junit.framework.TestCase.assertNotNull;
|
|
|
|
public class BehaviourSubjectSubscriptionTest {
|
|
|
|
@Test
|
|
public void test() throws InterruptedException {
|
|
Observable<String> observable = Observable.just("One", "Two", "Three");
|
|
BehaviorSubject<String> behaviorSubject = BehaviorSubject.create();
|
|
|
|
observable
|
|
.subscribeOn(Schedulers.io())
|
|
.subscribe(behaviorSubject);
|
|
behaviorSubject
|
|
//.subscribeOn(Schedulers.io())
|
|
.subscribe(System.out::println);
|
|
|
|
Thread.sleep(100);
|
|
|
|
String s = behaviorSubject.getValue();
|
|
assertNotNull(s);
|
|
}
|
|
}
|