本文整理汇总了Java中rx.observables.AsyncOnSubscribe类的典型用法代码示例。如果您正苦于以下问题:Java AsyncOnSubscribe类的具体用法?Java AsyncOnSubscribe怎么用?Java AsyncOnSubscribe使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AsyncOnSubscribe类属于rx.observables包,在下文中一共展示了AsyncOnSubscribe类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: example2
import rx.observables.AsyncOnSubscribe; //导入依赖的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;
}
}));
}
开发者ID:ArtTriumph,项目名称:RxJavaDemo,代码行数:25,代码来源:MainListWithExample_Observable_create.java
示例2: consume
import rx.observables.AsyncOnSubscribe; //导入依赖的package包/类
public Observable<GameOnEvent> consume() {
Log.log(Level.FINEST, this, "RXJava Observable [" + this.hashCode() + "] consume invoked. Obtaining dataProvider.");
KafkaRxAsyncDataProvider dp = dataProvider.get();
Action0 unsubscribeHandler = new Action0() {
@Override
public void call() {
Log.log(Level.FINEST, this, "RXJava Observable [" + KafkaRxJavaObservable.this.hashCode()
+ "] unsubscribe called, shutting down dataProvider.");
dp.shutdown();
Log.log(Level.FINEST, this, "RXJava Observable [" + KafkaRxJavaObservable.this.hashCode()
+ "] dataProvider shutdown complete.");
}
};
OnSubscribe<GameOnEvent> os = AsyncOnSubscribe.createStateless(dp.getCallback(), unsubscribeHandler);
// move subscribers to a new thread so they don't block on the data.
// if we hook unsubscribe here, we can unblock our polling waits..
// if not, then they expire when the next event comes in.
Observable<GameOnEvent> goo = Observable.create(os)
// .doOnUnsubscribe(() -> unsubscribeHandler.call())
.subscribeOn(Schedulers.from(executor));
return goo;
}
开发者ID:gameontext,项目名称:gameon-mediator,代码行数:26,代码来源:KafkaRxJavaObservable.java
示例3: example3
import rx.observables.AsyncOnSubscribe; //导入依赖的package包/类
private Observable example3() {
return Observable.create(AsyncOnSubscribe.createStateless(
new Action2<Long, Observer<Observable<? extends Integer>>>() {
@Override
public void call(Long requested, Observer<Observable<? extends Integer>> observer) {
observer.onNext(Observable.range(1, requested.intValue()));
observer.onCompleted();
}
}));
}
开发者ID:ArtTriumph,项目名称:RxJavaDemo,代码行数:11,代码来源:MainListWithExample_Observable_create.java
示例4: create
import rx.observables.AsyncOnSubscribe; //导入依赖的package包/类
@Experimental
public static <S, T> Observable<T> create(AsyncOnSubscribe<S, T> asyncOnSubscribe) {
return new Observable(hook.onCreate(asyncOnSubscribe));
}
开发者ID:JackChan1999,项目名称:letv,代码行数:5,代码来源:Observable.java
示例5: create
import rx.observables.AsyncOnSubscribe; //导入依赖的package包/类
public static <S, T> ReactiveSeq<T> create(AsyncOnSubscribe<S, T> asyncOnSubscribe) {
return reactiveSeq(Observable.create(asyncOnSubscribe));
}
开发者ID:aol,项目名称:cyclops,代码行数:4,代码来源:Observables.java
注:本文中的rx.observables.AsyncOnSubscribe类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论