本文整理了Java中rx.subjects.Subject.filter()
方法的一些代码示例,展示了Subject.filter()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Subject.filter()
方法的具体详情如下:
包路径:rx.subjects.Subject
类名称:Subject
方法名:filter
暂无
代码示例来源:origin: apptik/RHub
@Override
@SuppressWarnings("unchecked")
public <T> Observable<T> pub(final Class<T> filterClass) {
return subj.filter(new Func1<Object, Boolean>() {
@Override
public Boolean call(Object obj) {
return filterClass.isAssignableFrom(obj.getClass());
}
});
}
代码示例来源:origin: dswarm/dswarm
public Observable<Triple> getObservable() {
return tripleSubject.filter(NOT_NULL);
}
}
代码示例来源:origin: io.requery/requery
static <T> Observable<RxResult<T>> toResultObservable(final RxResult<T> result) {
final QueryElement<?> element = result.unwrapQuery();
// ensure the transaction listener is added in the target data store
result.addTransactionListener(typeChanges);
return typeChanges.commitSubject()
.filter(new Func1<Set<Type<?>>, Boolean>() {
@Override
public Boolean call(Set<Type<?>> types) {
return !Collections.disjoint(element.entityTypes(), types) ||
Types.referencesType(element.entityTypes(), types);
}
}).map(new Func1<Set<Type<?>>, RxResult<T>>() {
@Override
public RxResult<T> call(Set<Type<?>> types) {
return result;
}
}).startWith(result);
}
}
代码示例来源:origin: akarnokd/akarnokd-misc
public static <T, R> Observable.Transformer<T, R> switchFlatMap(
int n, Func1<T, Observable<R>> mapper) {
return f ->
Observable.defer(() -> {
final AtomicInteger ingress = new AtomicInteger();
final Subject<Integer, Integer> cancel =
PublishSubject.<Integer>create().toSerialized();
return f.flatMap(v -> {
int id = ingress.getAndIncrement();
Observable<R> o = mapper.call(v)
.takeUntil(cancel.filter(e -> e == id + n));
cancel.onNext(id);
return o;
});
})
;
}
}
内容来源于网络,如有侵权,请联系作者删除!