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


Java BehaviorProcessor.create方法代码示例

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


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

示例1: testBasicTransform

import io.reactivex.processors.BehaviorProcessor; //导入方法依赖的package包/类
@Test
public void testBasicTransform()
{
    BehaviorProcessor<List<Integer>> processor = BehaviorProcessor.create();
    FlowableList<Integer> list = FlowableList.diff(processor);
    TestSubscriber<Update<Integer>> test = list.updates().test();

    processor.onNext(Arrays.asList(1, 2, 3, 4));

    Update<Integer> firstUpdate = test.values().get(0);
    assertEquals(Collections.singletonList(Change.reloaded()), firstUpdate.changes);

    processor.onNext(Arrays.asList(2, 4, 5));

    Update<Integer> secondUpdate = test.values().get(1);

    assertEquals(Arrays.asList(2, 4, 5), secondUpdate.list);
    assertEquals(Arrays.asList(
            2, 4, 5),
            TestTools.applyChanges(firstUpdate.list, secondUpdate.list, secondUpdate.changes));
}
 
开发者ID:mproberts,项目名称:rxtools,代码行数:22,代码来源:DiffFlowableListTest.java

示例2: ReduxFXStore

import io.reactivex.processors.BehaviorProcessor; //导入方法依赖的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

示例3: SubjectMap

import io.reactivex.processors.BehaviorProcessor; //导入方法依赖的package包/类
/**
 * Constructs a new, empty SubjectMap
 */
public SubjectMap()
{
    ReadWriteLock _readWriteLock = new ReentrantReadWriteLock();

    _readLock = _readWriteLock.readLock();
    _writeLock = _readWriteLock.writeLock();

    _weakCache = new HashMap<>();
    _cache = new HashMap<>();
    _faults = BehaviorProcessor.create();

    _weakSources = new HashMap<>();
}
 
开发者ID:mproberts,项目名称:rxtools,代码行数:17,代码来源:SubjectMap.java

示例4: attachSource

import io.reactivex.processors.BehaviorProcessor; //导入方法依赖的package包/类
private Processor<V, V> attachSource(K key)
{
    _writeLock.lock();
    try {
        // if our source is being attached, we expect that all existing sources have been
        // cleaned up properly. If not, this is a serious issue
        assert(!_weakSources.containsKey(key));

        Processor<V, V> value = BehaviorProcessor.create();

        WeakReference<Flowable<V>> weakConnector = _weakCache.get(key);

        // if an observable is being attached then it must have been added to the weak cache
        // and it must still be referenced
        Flowable<V> connector = weakConnector.get();

        // the observable must be retained by someone since it is being attached
        assert(connector != null);

        // strongly retain the observable and add the subject so future next
        // calls will be piped through the subject
        _weakSources.put(key, new WeakReference<>(value));
        _cache.put(key, connector);

        return value;
    }
    finally {
        _writeLock.unlock();
    }
}
 
开发者ID:mproberts,项目名称:rxtools,代码行数:31,代码来源:SubjectMap.java

示例5: testSortedMoveOnly

import io.reactivex.processors.BehaviorProcessor; //导入方法依赖的package包/类
@Test
public void testSortedMoveOnly()
{
    final List<String> list1 = Arrays.asList("C", "B", "J", "D", "G", "H", "A", "I", "E", "F");
    final List<String> list2 = Arrays.asList("A", "B", "C", "D", "E", "F", "G", "H", "I", "J");

    BehaviorProcessor<List<String>> processor = BehaviorProcessor.create();
    FlowableList<String> list = FlowableList.diff(processor);
    TestSubscriber<Update<String>> test = list.updates().test();

    processor.onNext(list1);

    Update<String> firstUpdate = test.values().get(0);
    assertEquals(Collections.singletonList(Change.reloaded()), firstUpdate.changes);

    processor.onNext(list2);

    Update<String> secondUpdate = test.values().get(1);

    assertEquals(
            Arrays.asList("A", "B", "C", "D", "E", "F", "G", "H", "I", "J"),
            secondUpdate.list);

    assertEquals(
            Arrays.asList("A", "B", "C", "D", "E", "F", "G", "H", "I", "J"),
            TestTools.applyChanges(firstUpdate.list, secondUpdate.list, secondUpdate.changes));

    for (Change change : secondUpdate.changes) {
        assertEquals(change.type, Change.Type.Moved);
    }
}
 
开发者ID:mproberts,项目名称:rxtools,代码行数:32,代码来源:DiffFlowableListTest.java

示例6: testSortedIgnoreMoves

import io.reactivex.processors.BehaviorProcessor; //导入方法依赖的package包/类
@Test
public void testSortedIgnoreMoves()
{
    final List<String> list1 = Arrays.asList("C", "B", "J", "D", "G", "H", "A", "I", "E", "F");
    final List<String> list2 = Arrays.asList("A", "B", "C", "D", "E", "F", "G", "H", "I", "J");

    BehaviorProcessor<List<String>> processor = BehaviorProcessor.create();
    FlowableList<String> list = FlowableList.diff(processor, false);
    TestSubscriber<Update<String>> test = list.updates().test();

    processor.onNext(list1);

    Update<String> firstUpdate = test.values().get(0);
    assertEquals(Collections.singletonList(Change.reloaded()), firstUpdate.changes);

    processor.onNext(list2);

    Update<String> secondUpdate = test.values().get(1);

    assertEquals(
            Arrays.asList("A", "B", "C", "D", "E", "F", "G", "H", "I", "J"),
            secondUpdate.list);

    assertEquals(
            Arrays.asList("A", "B", "C", "D", "E", "F", "G", "H", "I", "J"),
            TestTools.applyChanges(firstUpdate.list, secondUpdate.list, secondUpdate.changes));

    for (Change change : secondUpdate.changes) {
        assertNotEquals(change.type, Change.Type.Moved);
    }
}
 
开发者ID:mproberts,项目名称:rxtools,代码行数:32,代码来源:DiffFlowableListTest.java

示例7: GCounter

import io.reactivex.processors.BehaviorProcessor; //导入方法依赖的package包/类
public GCounter(String nodeId, String crdtId) {
    super(nodeId, crdtId, BehaviorProcessor.create());
}
 
开发者ID:netopyr,项目名称:wurmloch-crdt,代码行数:4,代码来源:GCounter.java

示例8: PNCounter

import io.reactivex.processors.BehaviorProcessor; //导入方法依赖的package包/类
public PNCounter(String nodeId, String crtdId) {
    super(nodeId, crtdId, BehaviorProcessor.create());
}
 
开发者ID:netopyr,项目名称:wurmloch-crdt,代码行数:4,代码来源:PNCounter.java

示例9: LWWRegister

import io.reactivex.processors.BehaviorProcessor; //导入方法依赖的package包/类
public LWWRegister(String nodeId, String crdtId) {
    super(nodeId, crdtId, BehaviorProcessor.create());
    this.clock = new StrictVectorClock(nodeId);
}
 
开发者ID:netopyr,项目名称:wurmloch-crdt,代码行数:5,代码来源:LWWRegister.java

示例10: RequestBodyWrapper

import io.reactivex.processors.BehaviorProcessor; //导入方法依赖的package包/类
public RequestBodyWrapper(@NonNull RequestBody requestBody, String filePath) {
    this.mRequestBody = requestBody;
    this.mFilePath = filePath;
    this.mUploadProcessor = BehaviorProcessor.create();
}
 
开发者ID:nowandfurure,项目名称:richeditor,代码行数:6,代码来源:RequestBodyWrapper.java

示例11: behaviorProcessorProxy

import io.reactivex.processors.BehaviorProcessor; //导入方法依赖的package包/类
public static RxJava2ProcProxy behaviorProcessorProxy() {
    return new RxJava2ProcProxy(BehaviorProcessor.create(), Roxy.TePolicy.PASS);
}
 
开发者ID:apptik,项目名称:RHub,代码行数:4,代码来源:RxJava2Proxies.java

示例12: safeBehaviorProcessorProxy

import io.reactivex.processors.BehaviorProcessor; //导入方法依赖的package包/类
public static RxJava2ProcProxy safeBehaviorProcessorProxy() {
    return new RxJava2ProcProxy(BehaviorProcessor.create(), Roxy.TePolicy.WRAP);
}
 
开发者ID:apptik,项目名称:RHub,代码行数:4,代码来源:RxJava2Proxies.java

示例13: testAndShortCircuiting

import io.reactivex.processors.BehaviorProcessor; //导入方法依赖的package包/类
@Test
public void testAndShortCircuiting()
{
    BehaviorProcessor<Boolean> bool1 = BehaviorProcessor.create();
    BehaviorProcessor<Boolean> bool2 = BehaviorProcessor.create();
    BehaviorProcessor<Boolean> bool3 = BehaviorProcessor.create();
    BehaviorProcessor<Boolean> bool4 = BehaviorProcessor.create();

    bool1.onNext(true);
    bool2.onNext(true);
    bool3.onNext(true);
    bool4.onNext(true);

    Flowable<Boolean> joined = BooleanFlowables.and(bool1, bool2, bool3, bool4);

    TestSubscriber<Boolean> results = new TestSubscriber<>();

    joined.subscribe(results);

    results.assertValues(true);

    bool2.onNext(false);

    results.assertValues(true, false);

    bool3.onNext(false);

    results.assertValues(true, false);

    bool3.onNext(true);

    results.assertValues(true, false);

    bool2.onNext(true);

    results.assertValues(true, false, true);

    bool1.onNext(false);

    results.assertValues(true, false, true, false);

    bool4.onNext(false);

    results.assertValues(true, false, true, false);
}
 
开发者ID:mproberts,项目名称:rxtools,代码行数:46,代码来源:BooleanFlowablesTest.java

示例14: testOrShortCircuiting

import io.reactivex.processors.BehaviorProcessor; //导入方法依赖的package包/类
@Test
public void testOrShortCircuiting()
{
    BehaviorProcessor<Boolean> bool1 = BehaviorProcessor.create();
    BehaviorProcessor<Boolean> bool2 = BehaviorProcessor.create();
    BehaviorProcessor<Boolean> bool3 = BehaviorProcessor.create();
    BehaviorProcessor<Boolean> bool4 = BehaviorProcessor.create();

    bool1.onNext(true);
    bool2.onNext(false);
    bool3.onNext(false);
    bool4.onNext(false);

    Flowable<Boolean> joined = BooleanFlowables.or(bool1, bool2, bool3, bool4);

    TestSubscriber<Boolean> results = new TestSubscriber<>();

    joined.subscribe(results);

    results.assertValues(true);

    bool2.onNext(true);

    results.assertValues(true);

    bool1.onNext(false);

    results.assertValues(true);

    bool2.onNext(false);

    results.assertValues(true, false);

    bool3.onNext(true);

    results.assertValues(true, false, true);

    bool4.onNext(true);

    results.assertValues(true, false, true);

    bool4.onNext(false);

    results.assertValues(true, false, true);
}
 
开发者ID:mproberts,项目名称:rxtools,代码行数:46,代码来源:BooleanFlowablesTest.java


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