当前位置: 首页>>代码示例>>Java>>正文


Java Subject.onComplete方法代码示例

本文整理汇总了Java中rx.subjects.Subject.onComplete方法的典型用法代码示例。如果您正苦于以下问题:Java Subject.onComplete方法的具体用法?Java Subject.onComplete怎么用?Java Subject.onComplete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rx.subjects.Subject的用法示例。


在下文中一共展示了Subject.onComplete方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testNextWithOnlyUsingNextMethod

import rx.subjects.Subject; //导入方法依赖的package包/类
@Test
public void testNextWithOnlyUsingNextMethod() {
    Subject<String, String> obs = PublishSubject.create();
    Iterator<String> it = next(obs).iterator();
    fireOnNextInNewThread(obs, "one");
    assertEquals("one", it.next());

    fireOnNextInNewThread(obs, "two");
    assertEquals("two", it.next());

    obs.onComplete();
    try {
        it.next();
        fail("At the end of an iterator should throw a NoSuchElementException");
    } catch (NoSuchElementException e) {
    }
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:18,代码来源:BlockingOperatorNextTest.java

示例2: testNextWithCallingHasNextMultipleTimes

import rx.subjects.Subject; //导入方法依赖的package包/类
@Test
public void testNextWithCallingHasNextMultipleTimes() {
    Subject<String, String> obs = PublishSubject.create();
    Iterator<String> it = next(obs).iterator();
    fireOnNextInNewThread(obs, "one");
    assertTrue(it.hasNext());
    assertTrue(it.hasNext());
    assertTrue(it.hasNext());
    assertTrue(it.hasNext());
    assertEquals("one", it.next());

    obs.onComplete();
    try {
        it.next();
        fail("At the end of an iterator should throw a NoSuchElementException");
    } catch (NoSuchElementException e) {
    }
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:19,代码来源:BlockingOperatorNextTest.java

示例3: testMulticast

import rx.subjects.Subject; //导入方法依赖的package包/类
@Test
public void testMulticast() {
    Subject<String, String> source = PublishSubject.create();

    ConnectableObservable<String> multicasted = new OperatorMulticast<String, String>(source, new PublishSubjectFactory());

    @SuppressWarnings("unchecked")
    Observer<String> observer = mock(Observer.class);
    multicasted.subscribe(observer);

    source.onNext("one");
    source.onNext("two");

    multicasted.connect();

    source.onNext("three");
    source.onNext("four");
    source.onComplete();

    verify(observer, never()).onNext("one");
    verify(observer, never()).onNext("two");
    verify(observer, times(1)).onNext("three");
    verify(observer, times(1)).onNext("four");
    verify(observer, times(1)).onComplete();

}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:27,代码来源:OnSubscribeMulticastTest.java

示例4: testMulticastConnectTwice

import rx.subjects.Subject; //导入方法依赖的package包/类
@Test
public void testMulticastConnectTwice() {
    Subject<String, String> source = PublishSubject.create();

    ConnectableObservable<String> multicasted = new OperatorMulticast<String, String>(source, new PublishSubjectFactory());

    @SuppressWarnings("unchecked")
    Observer<String> observer = mock(Observer.class);
    multicasted.subscribe(observer);

    source.onNext("one");

    multicasted.connect();
    multicasted.connect();

    source.onNext("two");
    source.onComplete();

    verify(observer, never()).onNext("one");
    verify(observer, times(1)).onNext("two");
    verify(observer, times(1)).onComplete();

}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:24,代码来源:OnSubscribeMulticastTest.java

示例5: testMostRecent

import rx.subjects.Subject; //导入方法依赖的package包/类
@Test
public void testMostRecent() {
    Subject<String, String> s = PublishSubject.create();

    Iterator<String> it = mostRecent(s, "default").iterator();

    assertTrue(it.hasNext());
    assertEquals("default", it.next());
    assertEquals("default", it.next());

    s.onNext("one");
    assertTrue(it.hasNext());
    assertEquals("one", it.next());
    assertEquals("one", it.next());

    s.onNext("two");
    assertTrue(it.hasNext());
    assertEquals("two", it.next());
    assertEquals("two", it.next());

    s.onComplete();
    assertFalse(it.hasNext());

}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:25,代码来源:BlockingOperatorMostRecentTest.java

示例6: testMulticastDisconnect

import rx.subjects.Subject; //导入方法依赖的package包/类
@Test
public void testMulticastDisconnect() {
    Subject<String, String> source = PublishSubject.create();

    ConnectableObservable<String> multicasted = new OperatorMulticast<String, String>(source, new PublishSubjectFactory());

    @SuppressWarnings("unchecked")
    Observer<String> observer = mock(Observer.class);
    multicasted.subscribe(observer);

    source.onNext("one");

    Subscription connection = multicasted.connect();
    source.onNext("two");

    connection.unsubscribe();
    source.onNext("three");

    // subscribe again
    multicasted.subscribe(observer);
    // reconnect
    multicasted.connect();
    source.onNext("four");
    source.onComplete();

    verify(observer, never()).onNext("one");
    verify(observer, times(1)).onNext("two");
    verify(observer, never()).onNext("three");
    verify(observer, times(1)).onNext("four");
    verify(observer, times(1)).onComplete();

}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:33,代码来源:OnSubscribeMulticastTest.java

示例7: testMulticastConnectTwice

import rx.subjects.Subject; //导入方法依赖的package包/类
@Test
public void testMulticastConnectTwice() {
    Subject<String, String> source = PublishSubject.create();

    ConnectableObservable<String> multicasted = new OperatorMulticast<String, String>(source, new PublishSubjectFactory());

    @SuppressWarnings("unchecked")
    Observer<String> observer = mock(Observer.class);
    multicasted.subscribe(observer);

    source.onNext("one");

    Subscription sub = multicasted.connect();
    Subscription sub2 = multicasted.connect();
    
    source.onNext("two");
    source.onComplete();

    verify(observer, never()).onNext("one");
    verify(observer, times(1)).onNext("two");
    verify(observer, times(1)).onComplete();
    
    assertEquals(sub, sub2);

}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:26,代码来源:OperatorMulticastTest.java


注:本文中的rx.subjects.Subject.onComplete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。