本文整理汇总了Java中com.github.davidmoten.rx.Functions.alwaysTrue2方法的典型用法代码示例。如果您正苦于以下问题:Java Functions.alwaysTrue2方法的具体用法?Java Functions.alwaysTrue2怎么用?Java Functions.alwaysTrue2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.davidmoten.rx.Functions
的用法示例。
在下文中一共展示了Functions.alwaysTrue2方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testStateTransitionThrowsError
import com.github.davidmoten.rx.Functions; //导入方法依赖的package包/类
@Test
public void testStateTransitionThrowsError() {
final RuntimeException ex = new RuntimeException("boo");
Func0<Integer> initialState = Functions.constant0(1);
Func3<Integer, Integer, Observer<Integer>, Integer> transition = new Func3<Integer, Integer, Observer<Integer>, Integer>() {
@Override
public Integer call(Integer collection, Integer t, Observer<Integer> observer) {
throw ex;
}
};
Func2<Integer, Observer<Integer>, Boolean> completion = Functions.alwaysTrue2();
Transformer<Integer, Integer> transformer = Transformers.stateMachine(initialState,
transition, completion);
TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
Observable.just(1, 1, 1).compose(transformer).subscribe(ts);
ts.awaitTerminalEvent();
ts.assertError(ex);
}
示例2: testUnsubscriptionFromTransition
import com.github.davidmoten.rx.Functions; //导入方法依赖的package包/类
@Test
public void testUnsubscriptionFromTransition() {
Func0<Integer> initialState = Functions.constant0(1);
Func3<Integer, Integer, Subscriber<Integer>, Integer> transition = new Func3<Integer, Integer, Subscriber<Integer>, Integer>() {
@Override
public Integer call(Integer collection, Integer t, Subscriber<Integer> subscriber) {
subscriber.onNext(123);
subscriber.unsubscribe();
return 1;
}
};
Func2<Integer, Observer<Integer>, Boolean> completion = Functions.alwaysTrue2();
Transformer<Integer, Integer> transformer = Transformers.stateMachine(initialState,
transition, completion);
TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
Observable.just(1, 1, 1).repeat().compose(transformer).subscribe(ts);
ts.assertValue(123);
ts.assertCompleted();
ts.assertUnsubscribed();
}
示例3: testForCompletionWithinStateMachine
import com.github.davidmoten.rx.Functions; //导入方法依赖的package包/类
@Test
public void testForCompletionWithinStateMachine() {
Func0<Integer> initialState = Functions.constant0(1);
Func3<Integer, Integer, Subscriber<Integer>, Integer> transition = new Func3<Integer, Integer, Subscriber<Integer>, Integer>() {
@Override
public Integer call(Integer collection, Integer t, Subscriber<Integer> subscriber) {
subscriber.onNext(123);
// complete from within transition
subscriber.onCompleted();
return 1;
}
};
Func2<? super Integer, ? super Subscriber<Integer>, Boolean> completion = Functions
.alwaysTrue2();
Transformer<Integer, Integer> transformer = Transformers.stateMachine(initialState,
transition, completion);
TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
final AtomicInteger count = new AtomicInteger(0);
Observable.just(1, 2, 3).doOnNext(Actions.increment1(count)).compose(transformer)
.subscribe(ts);
ts.assertValues(123);
ts.assertCompleted();
assertEquals(1, count.get());
}