本文整理汇总了Java中io.reactivex.processors.BehaviorProcessor类的典型用法代码示例。如果您正苦于以下问题:Java BehaviorProcessor类的具体用法?Java BehaviorProcessor怎么用?Java BehaviorProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BehaviorProcessor类属于io.reactivex.processors包,在下文中一共展示了BehaviorProcessor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例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);
}
示例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);
}
示例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<>();
}
示例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();
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例9: RunStateServiceImpl
import io.reactivex.processors.BehaviorProcessor; //导入依赖的package包/类
public RunStateServiceImpl(RunState initialState) {
runState = BehaviorProcessor.createDefault(requireNonNull(initialState, "initial state must not be null"));
}
示例10: GCounter
import io.reactivex.processors.BehaviorProcessor; //导入依赖的package包/类
public GCounter(String nodeId, String crdtId) {
super(nodeId, crdtId, BehaviorProcessor.create());
}
示例11: PNCounter
import io.reactivex.processors.BehaviorProcessor; //导入依赖的package包/类
public PNCounter(String nodeId, String crtdId) {
super(nodeId, crtdId, BehaviorProcessor.create());
}
示例12: LWWRegister
import io.reactivex.processors.BehaviorProcessor; //导入依赖的package包/类
public LWWRegister(String nodeId, String crdtId) {
super(nodeId, crdtId, BehaviorProcessor.create());
this.clock = new StrictVectorClock(nodeId);
}
示例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();
}
示例14: behaviorProcessorProxy
import io.reactivex.processors.BehaviorProcessor; //导入依赖的package包/类
public static RxJava2ProcProxy behaviorProcessorProxy() {
return new RxJava2ProcProxy(BehaviorProcessor.create(), Roxy.TePolicy.PASS);
}
示例15: serializedBehaviorProcessorProxy
import io.reactivex.processors.BehaviorProcessor; //导入依赖的package包/类
public static RxJava2ProcProxy serializedBehaviorProcessorProxy() {
return new RxJava2ProcProxy(BehaviorProcessor.create().toSerialized(), Roxy.TePolicy.PASS);
}