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


Java FlowableProcessor.onNext方法代码示例

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


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

示例1: receiveDownloadEvent

import io.reactivex.processors.FlowableProcessor; //导入方法依赖的package包/类
/**
 * Receive the url download event.
 * <p>
 * Will receive the following event:
 * {@link DownloadFlag#NORMAL}、{@link DownloadFlag#WAITING}、
 * {@link DownloadFlag#STARTED}、{@link DownloadFlag#PAUSED}、
 * {@link DownloadFlag#COMPLETED}、{@link DownloadFlag#FAILED};
 * <p>
 * Every event has {@link DownloadStatus}, you can get it and display it on the interface.
 *
 * @param url url
 * @return DownloadEvent
 */
public FlowableProcessor<DownloadEvent> receiveDownloadEvent(String url) {
    FlowableProcessor<DownloadEvent> processor = createProcessor(url, processorMap);
    DownloadMission mission = missionMap.get(url);
    if (mission == null) {  //Not yet add this url mission.
        DownloadRecord record = dataBaseHelper.readSingleRecord(url);
        if (record == null) {
            processor.onNext(normal(null));
        } else {
            File file = getFiles(record.getSaveName(), record.getSavePath())[0];
            if (file.exists()) {
                processor.onNext(createEvent(record.getFlag(), record.getStatus()));
            } else {
                processor.onNext(normal(null));
            }
        }
    }
    return processor;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:32,代码来源:DownloadService.java

示例2: post

import io.reactivex.processors.FlowableProcessor; //导入方法依赖的package包/类
/**
 * 触发事件
 *
 * @param content
 */
@SuppressWarnings({"unchecked", "rawtypes"})
public void post(@NonNull Object tag, @NonNull Object content) {
    List<FlowableProcessor> processors = mProcessorMapper.get(tag);
    if (!isEmpty(processors)) {
        for (FlowableProcessor processor : processors) {
            processor.onNext(content);
        }
    }
}
 
开发者ID:ynztlxdeai,项目名称:MVPtemplate,代码行数:15,代码来源:RxBus.java

示例3: flowProcessorToFlowableProcessor

import io.reactivex.processors.FlowableProcessor; //导入方法依赖的package包/类
@Test
public void flowProcessorToFlowableProcessor() {
    TestFlowProcessor<Integer> tfp = new TestFlowProcessor<>();

    FlowableProcessor<Integer> fp = FlowInterop.fromFlowProcessor(tfp);

    assertFalse(fp.hasSubscribers());
    assertFalse(fp.hasComplete());
    assertFalse(fp.hasThrowable());
    assertNull(fp.getThrowable());

    TestSubscriber<Integer> ts = fp.test();

    assertTrue(fp.hasSubscribers());
    assertFalse(fp.hasComplete());
    assertFalse(fp.hasThrowable());
    assertNull(fp.getThrowable());

    fp.onNext(1);
    fp.onNext(2);
    fp.onNext(3);
    fp.onNext(4);
    fp.onNext(5);
    fp.onComplete();

    assertFalse(fp.hasSubscribers());
    assertTrue(fp.hasComplete());
    assertFalse(fp.hasThrowable());
    assertNull(fp.getThrowable());

    ts.assertResult(1, 2, 3, 4, 5);
}
 
开发者ID:akarnokd,项目名称:RxJava2Jdk9Interop,代码行数:33,代码来源:FlowInteropTest.java

示例4: flowProcessorToFlowableProcessorTake

import io.reactivex.processors.FlowableProcessor; //导入方法依赖的package包/类
@Test
public void flowProcessorToFlowableProcessorTake() {
    TestFlowProcessor<Integer> tfp = new TestFlowProcessor<>();

    FlowableProcessor<Integer> fp = FlowInterop.fromFlowProcessor(tfp);

    assertFalse(fp.hasSubscribers());
    assertFalse(fp.hasComplete());
    assertFalse(fp.hasThrowable());
    assertNull(fp.getThrowable());

    TestSubscriber<Integer> ts = fp.take(3).test();

    assertTrue(fp.hasSubscribers());
    assertFalse(fp.hasComplete());
    assertFalse(fp.hasThrowable());
    assertNull(fp.getThrowable());

    fp.onNext(1);
    fp.onNext(2);
    fp.onNext(3);

    assertFalse(fp.hasSubscribers());
    assertFalse(fp.hasComplete());
    assertFalse(fp.hasThrowable());
    assertNull(fp.getThrowable());

    fp.onNext(4);
    fp.onNext(5);
    fp.onComplete();

    assertFalse(fp.hasSubscribers());
    assertTrue(fp.hasComplete());
    assertFalse(fp.hasThrowable());
    assertNull(fp.getThrowable());

    ts.assertResult(1, 2, 3);
}
 
开发者ID:akarnokd,项目名称:RxJava2Jdk9Interop,代码行数:39,代码来源:FlowInteropTest.java

示例5: flowProcessorToFlowableProcessorError

import io.reactivex.processors.FlowableProcessor; //导入方法依赖的package包/类
@Test
public void flowProcessorToFlowableProcessorError() {
    TestFlowProcessor<Integer> tfp = new TestFlowProcessor<>();

    FlowableProcessor<Integer> fp = FlowInterop.fromFlowProcessor(tfp);

    assertFalse(fp.hasSubscribers());
    assertFalse(fp.hasComplete());
    assertFalse(fp.hasThrowable());
    assertNull(fp.getThrowable());

    TestSubscriber<Integer> ts = fp.test();

    assertTrue(fp.hasSubscribers());
    assertFalse(fp.hasComplete());
    assertFalse(fp.hasThrowable());
    assertNull(fp.getThrowable());

    fp.onNext(1);
    fp.onNext(2);
    fp.onNext(3);
    fp.onNext(4);
    fp.onNext(5);
    fp.onError(new IOException());

    assertFalse(fp.hasSubscribers());
    assertFalse(fp.hasComplete());
    assertTrue(fp.hasThrowable());
    assertNotNull(fp.getThrowable());

    ts.assertFailure(IOException.class, 1, 2, 3, 4, 5);
}
 
开发者ID:akarnokd,项目名称:RxJava2Jdk9Interop,代码行数:33,代码来源:FlowInteropTest.java


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