本文整理汇总了Java中io.reactivex.processors.BehaviorProcessor类的典型用法代码示例。如果您正苦于以下问题:Java BehaviorProcessor类的具体用法?Java BehaviorProcessor怎么用?Java BehaviorProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BehaviorProcessor类属于io.reactivex.processors包,在下文中一共展示了BehaviorProcessor类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: createProcessor
import io.reactivex.processors.BehaviorProcessor; //导入依赖的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
示例4: 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
示例5: 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
示例6: 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
示例7: 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
示例8: ObservableChoosable
import io.reactivex.processors.BehaviorProcessor; //导入依赖的package包/类
private ObservableChoosable(Iterable<T> allValues, T defaultValue) {
requireNonNull(defaultValue, "the default value must not be null");
requireNonNull(allValues, "allValues must not be null");
this.actualValueSubject = BehaviorProcessor.createDefault(defaultValue);
this.allValuesSubject = BehaviorProcessor.createDefault(allValues);
}
开发者ID:streamingpool,项目名称:streamingpool-core,代码行数:7,代码来源:ObservableChoosable.java
示例9: RunStateServiceImpl
import io.reactivex.processors.BehaviorProcessor; //导入依赖的package包/类
public RunStateServiceImpl(RunState initialState) {
runState = BehaviorProcessor.createDefault(requireNonNull(initialState, "initial state must not be null"));
}
开发者ID:streamingpool,项目名称:streamingpool-core,代码行数:4,代码来源:RunStateServiceImpl.java
示例10: 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
示例11: 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
示例12: 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
示例13: 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
示例14: 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
示例15: serializedBehaviorProcessorProxy
import io.reactivex.processors.BehaviorProcessor; //导入依赖的package包/类
public static RxJava2ProcProxy serializedBehaviorProcessorProxy() {
return new RxJava2ProcProxy(BehaviorProcessor.create().toSerialized(), Roxy.TePolicy.PASS);
}
开发者ID:apptik,项目名称:RHub,代码行数:4,代码来源:RxJava2Proxies.java
示例16: 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
示例17: safeSerializedBehaviorProcessorProxy
import io.reactivex.processors.BehaviorProcessor; //导入依赖的package包/类
public static RxJava2ProcProxy safeSerializedBehaviorProcessorProxy() {
return new RxJava2ProcProxy(BehaviorProcessor.create().toSerialized(), Roxy.TePolicy.WRAP);
}
开发者ID:apptik,项目名称:RHub,代码行数:4,代码来源:RxJava2Proxies.java
示例18: 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
示例19: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论