本文整理汇总了Java中rx.functions.Func3类的典型用法代码示例。如果您正苦于以下问题:Java Func3类的具体用法?Java Func3怎么用?Java Func3使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Func3类属于rx.functions包,在下文中一共展示了Func3类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: example2
import rx.functions.Func3; //导入依赖的package包/类
private Observable example2() {
return Observable.create(AsyncOnSubscribe.createStateful(
new Func0<Integer>() {
@Override
public Integer call() {
return 1;
}
},
new Func3<Integer, Long, Observer<Observable<? extends Integer>>, Integer>() {
@Override
public Integer call(Integer state, Long requested, Observer<Observable<? extends Integer>> observer) {
if (state == 1) {
Observable<Integer> o1 = Observable.just(1, 2, 3, 4)
.delay(300, TimeUnit.MILLISECONDS);
observer.onNext(o1);
} else if (state == 2) {
Observable<Integer> o = Observable.just(5, 6, 7, 8);
observer.onNext(o);
} else
observer.onCompleted();
return state + 1;
}
}));
}
示例2: requestSound
import rx.functions.Func3; //导入依赖的package包/类
private Func1<SoundModel, Observable<SoundModel>> requestSound(
Func3<String, SoundSystem.Type, SoundSystem.Source, SoundSystem> request,
Func2<OpenSession, SoundModel, SoundModel> handler) {
return sound -> commonService.findClient(sound.getGatewayUuid())
.send(request.call(sound.getWhere(), sound.getSoundSystemType(), sound.getSoundSystemSource()))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.map(openSession -> handler.call(openSession, sound))
.onErrorReturn(throwable -> {
log.warn("sound={} | failing request={}", sound.getUuid(),
request.call(sound.getWhere(), sound.getSoundSystemType(), sound.getSoundSystemSource()).getValue());
// unreadable status
return sound;
});
}
示例3: testCombineLatest3TypesA
import rx.functions.Func3; //导入依赖的package包/类
@SuppressWarnings("unchecked")
/* mock calls don't do generics */
@Test
public void testCombineLatest3TypesA() {
Func3<String, Integer, int[], String> combineLatestFunction = getConcatStringIntegerIntArrayCombineLatestFunction();
/* define a Observer to receive aggregated events */
Observer<String> observer = mock(Observer.class);
Observable<String> w = Observable.combineLatest(Observable.just("one", "two"), Observable.just(2), Observable.just(new int[] { 4, 5, 6 }), combineLatestFunction);
w.subscribe(observer);
verify(observer, never()).onError(any(Throwable.class));
verify(observer, times(1)).onComplete();
verify(observer, times(1)).onNext("two2[4, 5, 6]");
}
示例4: testCombineLatest3TypesB
import rx.functions.Func3; //导入依赖的package包/类
@SuppressWarnings("unchecked")
/* mock calls don't do generics */
@Test
public void testCombineLatest3TypesB() {
Func3<String, Integer, int[], String> combineLatestFunction = getConcatStringIntegerIntArrayCombineLatestFunction();
/* define a Observer to receive aggregated events */
Observer<String> observer = mock(Observer.class);
Observable<String> w = Observable.combineLatest(Observable.just("one"), Observable.just(2), Observable.just(new int[] { 4, 5, 6 }, new int[] { 7, 8 }), combineLatestFunction);
w.subscribe(observer);
verify(observer, never()).onError(any(Throwable.class));
verify(observer, times(1)).onComplete();
verify(observer, times(1)).onNext("one2[4, 5, 6]");
verify(observer, times(1)).onNext("one2[7, 8]");
}
示例5: getConcat3StringsCombineLatestFunction
import rx.functions.Func3; //导入依赖的package包/类
private Func3<String, String, String, String> getConcat3StringsCombineLatestFunction() {
Func3<String, String, String, String> combineLatestFunction = new Func3<String, String, String, String>() {
@Override
public String call(String a1, String a2, String a3) {
if (a1 == null) {
a1 = "";
}
if (a2 == null) {
a2 = "";
}
if (a3 == null) {
a3 = "";
}
return a1 + a2 + a3;
}
};
return combineLatestFunction;
}
示例6: test3SourcesOverload
import rx.functions.Func3; //导入依赖的package包/类
@Test
public void test3SourcesOverload() {
Observable<Integer> s1 = Observable.just(1);
Observable<Integer> s2 = Observable.just(2);
Observable<Integer> s3 = Observable.just(3);
Observable<List<Integer>> result = Observable.combineLatest(s1, s2, s3,
new Func3<Integer, Integer, Integer, List<Integer>>() {
@Override
public List<Integer> call(Integer t1, Integer t2, Integer t3) {
return Arrays.asList(t1, t2, t3);
}
});
@SuppressWarnings("unchecked")
Observer<Object> o = mock(Observer.class);
result.subscribe(o);
verify(o).onNext(Arrays.asList(1, 2, 3));
verify(o).onComplete();
verify(o, never()).onError(any(Throwable.class));
}
示例7: testStart3Types
import rx.functions.Func3; //导入依赖的package包/类
@SuppressWarnings("unchecked")
/* mock calls don't do generics */
@Test
public void testStart3Types() {
Func3<String, Integer, int[], String> zipr = getConcatStringIntegerIntArrayZipr();
/* define a Observer to receive aggregated events */
Observer<String> observer = mock(Observer.class);
Observable<String> w = Observable.zip(Observable.just("one", "two"), Observable.just(2), Observable.just(new int[] { 4, 5, 6 }), zipr);
w.subscribe(observer);
verify(observer, never()).onError(any(Throwable.class));
verify(observer, times(1)).onComplete();
verify(observer, times(1)).onNext("one2[4, 5, 6]");
verify(observer, never()).onNext("two");
}
示例8: getConcat3StringsZipr
import rx.functions.Func3; //导入依赖的package包/类
private Func3<String, String, String, String> getConcat3StringsZipr() {
Func3<String, String, String, String> zipr = new Func3<String, String, String, String>() {
@Override
public String call(String a1, String a2, String a3) {
if (a1 == null) {
a1 = "";
}
if (a2 == null) {
a2 = "";
}
if (a3 == null) {
a3 = "";
}
return a1 + a2 + a3;
}
};
return zipr;
}
示例9: testStateTransitionThrowsError
import rx.functions.Func3; //导入依赖的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);
}
示例10: testUnsubscriptionFromTransition
import rx.functions.Func3; //导入依赖的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();
}
示例11: testForCompletionWithinStateMachine
import rx.functions.Func3; //导入依赖的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());
}
示例12: createSingleState
import rx.functions.Func3; //导入依赖的package包/类
@Experimental
public static <S, T> Observable$OnSubscribe<T> createSingleState(Func0<? extends S> generator, final Action3<? super S, Long, ? super Observer<Observable<? extends T>>> next) {
return new AsyncOnSubscribeImpl((Func0) generator, new Func3<S, Long, Observer<Observable<? extends T>>, S>() {
public S call(S state, Long requested, Observer<Observable<? extends T>> subscriber) {
next.call(state, requested, subscriber);
return state;
}
});
}
示例13: createStateless
import rx.functions.Func3; //导入依赖的package包/类
@Experimental
public static <T> Observable$OnSubscribe<T> createStateless(final Action2<Long, ? super Observer<Observable<? extends T>>> next) {
return new AsyncOnSubscribeImpl(new Func3<Void, Long, Observer<Observable<? extends T>>, Void>() {
public Void call(Void state, Long requested, Observer<Observable<? extends T>> subscriber) {
next.call(requested, subscriber);
return state;
}
});
}
示例14: simpleFind
import rx.functions.Func3; //导入依赖的package包/类
private boolean simpleFind(CodeArea area, String text, int offset) {
Func3<String, String, Integer, Integer> func = caseSensitive.isSelected() ? String::indexOf
: StringUtil::indexOfIgnoreCase;
int index = func.call(area.getText(), text, offset);
if (index != -1) {
area.selectRange(index, index + text.length());
return true;
}
return false;
}
示例15: drop
import rx.functions.Func3; //导入依赖的package包/类
@RxLogObservable
public Observable<Void> drop() {
Observable<Object> serverObserver = storIOSQLite
.executeSQL()
.withQuery(ServersTable.QUERY_DROP)
.prepare()
.asRxObservable();
Observable<Object> usersObserver = storIOSQLite
.executeSQL()
.withQuery(UsersTable.QUERY_DROP)
.prepare()
.asRxObservable();
Observable<Object> devicesObserver = storIOSQLite
.executeSQL()
.withQuery(DevicesTable.QUERY_DROP)
.prepare()
.asRxObservable();
return Observable.zip(
serverObserver,
usersObserver,
devicesObserver,
new Func3<Object, Object, Object, Void>() {
@Override
public Void call(Object o, Object o2, Object o3) {
return null;
}
}
)
.onErrorReturn(throwable -> null);
}