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


Java FlowableProcessor类代码示例

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


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

示例1: init

import io.reactivex.processors.FlowableProcessor; //导入依赖的package包/类
@Override
public void init(Map<String, DownloadMission> missionMap,
                 Map<String, FlowableProcessor<DownloadEvent>> processorMap) {
    DownloadMission mission = missionMap.get(getUrl());
    if (mission == null) {
        missionMap.put(getUrl(), this);
    } else {
        if (mission.isCanceled()) {
            missionMap.put(getUrl(), this);
        } else {
            throw new IllegalArgumentException(formatStr(Constant.DOWNLOAD_URL_EXISTS, getUrl()));
        }
    }

    this.processor = createProcessor(getUrl(), processorMap);

    for (SingleMission each : missions) {
        each.init(missionMap, processorMap);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:MultiMission.java

示例2: 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

示例3: ReduxFXStore

import io.reactivex.processors.FlowableProcessor; //导入依赖的package包/类
@SafeVarargs
public ReduxFXStore(S initialState, BiFunction<S, Object, Update<S>> updater, Middleware<S>... middlewares) {
    final BiFunction<S, Object, Update<S>> chainedUpdater = applyMiddlewares(updater, middlewares);

    final Publisher<Object> actionPublisher =
            Flowable.create(actionEmitter -> this.actionEmitter = actionEmitter, BackpressureStrategy.BUFFER);

    final FlowableProcessor<Update<S>> updateProcessor = BehaviorProcessor.create();

    statePublisher = updateProcessor.map(Update::getState)
            .startWith(initialState);

    statePublisher.zipWith(actionPublisher, chainedUpdater::apply)
            .subscribe(updateProcessor);

    commandPublisher = updateProcessor
            .map(Update::getCommands)
            .flatMapIterable(commands -> commands);
}
 
开发者ID:netopyr,项目名称:reduxfx,代码行数:20,代码来源:ReduxFXStore.java

示例4: init

import io.reactivex.processors.FlowableProcessor; //导入依赖的package包/类
@Override
public void init(Map<String, DownloadMission> missionMap,
                 Map<String, FlowableProcessor<DownloadEvent>> processorMap) {
    DownloadMission mission = missionMap.get(getUrl());
    if (mission == null) {
        missionMap.put(getUrl(), this);
    } else {
        if (mission.isCanceled()) {
            missionMap.put(getUrl(), this);
        } else {
            throw new IllegalArgumentException(formatStr(Constant.DOWNLOAD_URL_EXISTS, getUrl()));
        }
    }
    this.processor = createProcessor(getUrl(), processorMap);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:SingleMission.java

示例5: createProcessor

import io.reactivex.processors.FlowableProcessor; //导入依赖的package包/类
public static FlowableProcessor<DownloadEvent> createProcessor(
        String missionId, Map<String, FlowableProcessor<DownloadEvent>> processorMap) {

    if (processorMap.get(missionId) == null) {
        FlowableProcessor<DownloadEvent> processor =
                BehaviorProcessor.<DownloadEvent>create().toSerialized();
        processorMap.put(missionId, processor);
    }
    return processorMap.get(missionId);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:Utils.java

示例6: register

import io.reactivex.processors.FlowableProcessor; //导入依赖的package包/类
public <T> Flowable<T> register(@NonNull Object tag) {
    List<FlowableProcessor> processors = mProcessorMapper.get(tag);
    if (null == processors) {
        processors = new ArrayList<FlowableProcessor>();
        mProcessorMapper.put(tag, processors);
    }
    FlowableProcessor<T> processor;
    processors.add(processor = PublishProcessor.create());
    return processor;
}
 
开发者ID:ynztlxdeai,项目名称:MVPtemplate,代码行数:11,代码来源:RxBus.java

示例7: unregister

import io.reactivex.processors.FlowableProcessor; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public void unregister(@NonNull Object tag) {
    List<FlowableProcessor> processors = mProcessorMapper.get(tag);
    if (null != processors) {
        mProcessorMapper.remove(tag);
    }
}
 
开发者ID:ynztlxdeai,项目名称:MVPtemplate,代码行数:8,代码来源:RxBus.java

示例8: 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

示例9: fromFlowProcessor

import io.reactivex.processors.FlowableProcessor; //导入依赖的package包/类
/**
 * Wraps a Flow.Processor (identity) into a FlowableProcessor.
 * @param source the source Flow.Processor, not null
 * @param <T> the input and output type of the Flow.Processor
 * @return the new FlowableProcessor instance
 * @throws  NullPointerException if source is null
 */
@SuppressWarnings("unchecked")
public static <T> FlowableProcessor<T> fromFlowProcessor(Flow.Processor<T, T> source) {
    if (source instanceof FlowableProcessor) {
        return (FlowableProcessor<T>)source;
    }
    ObjectHelper.requireNonNull(source, "source is null");
    return new FlowableProcessorFromFlowProcessor<>(source);
}
 
开发者ID:akarnokd,项目名称:RxJava2Jdk9Interop,代码行数:16,代码来源:FlowInterop.java

示例10: 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

示例11: 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

示例12: 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

示例13: getIntegerChangedCommandFlowable

import io.reactivex.processors.FlowableProcessor; //导入依赖的package包/类
private Flowable<IntegerChangedCommand> getIntegerChangedCommandFlowable() {
    if (integerChangedCommandFlowable == null) {
        final FlowableProcessor<IntegerChangedCommand> processor = PublishProcessor.create();
        commandProcessor
                .filter(command -> command instanceof IntegerChangedCommand)
                .map(command -> (IntegerChangedCommand) command)
                .subscribe(processor);
        integerChangedCommandFlowable = processor;
    }
    return integerChangedCommandFlowable;
}
 
开发者ID:netopyr,项目名称:reduxfx,代码行数:12,代码来源:ComponentDriver.java

示例14: getObjectChangedCommandFlowable

import io.reactivex.processors.FlowableProcessor; //导入依赖的package包/类
private Flowable<ObjectChangedCommand<?>> getObjectChangedCommandFlowable() {
    if (objectChangedCommandFlowable == null) {
        final FlowableProcessor<ObjectChangedCommand<?>> processor = PublishProcessor.create();
        commandProcessor
                .filter(command -> command instanceof ObjectChangedCommand)
                .map(command -> (ObjectChangedCommand<?>) command)
                .subscribe(processor);
        objectChangedCommandFlowable = processor;
    }
    return objectChangedCommandFlowable;
}
 
开发者ID:netopyr,项目名称:reduxfx,代码行数:12,代码来源:ComponentDriver.java

示例15: getFireEventCommandFlowable

import io.reactivex.processors.FlowableProcessor; //导入依赖的package包/类
private Flowable<FireEventCommand<? extends Event>> getFireEventCommandFlowable() {
    if (fireEventCommandFlowable == null) {
        final FlowableProcessor<FireEventCommand<? extends Event>> processor = PublishProcessor.create();
        commandProcessor
                .filter(command -> command instanceof FireEventCommand)
                .map(command -> (FireEventCommand<? extends Event>) command)
                .subscribe(processor);
        fireEventCommandFlowable = processor;
    }
    return fireEventCommandFlowable;
}
 
开发者ID:netopyr,项目名称:reduxfx,代码行数:12,代码来源:ComponentDriver.java


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