本文整理汇总了Java中rx.subjects.ReplaySubject.subscribe方法的典型用法代码示例。如果您正苦于以下问题:Java ReplaySubject.subscribe方法的具体用法?Java ReplaySubject.subscribe怎么用?Java ReplaySubject.subscribe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rx.subjects.ReplaySubject
的用法示例。
在下文中一共展示了ReplaySubject.subscribe方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: replaySubject
import rx.subjects.ReplaySubject; //导入方法依赖的package包/类
public static void replaySubject() {
ReplaySubject<Integer> subject = ReplaySubject.create();
subject.onNext(5);
Action1<Integer> action1 = integer -> Log.i("From action1", String.valueOf(integer));
Subscription subscription1 = subject.subscribe(action1);
subject.onNext(10);
Action1<Integer> action2 = integer -> Log.i("From action2", String.valueOf(integer));
Subscription subscription2 = subject.subscribe(action2);
subject.onNext(20);
subscription1.unsubscribe();
subject.onNext(40);
subscription2.unsubscribe();
subject.onNext(80);
}
示例2: zugSuchen
import rx.subjects.ReplaySubject; //导入方法依赖的package包/类
@Override
public final void zugSuchen(Stellung stellung, Observer<Zug> subject) {
Collection<Zug> zuege = spielregeln.liefereGueltigeZuege(stellung);
if (zuege.size() > 0) {
ReplaySubject<BewerteterZug> suchErgebnisse = ReplaySubject.create();
aktuelleSuchErgebnisse = suchErgebnisse;
ErgebnisMelden melder = new ErgebnisMelden(subject, zuege.size());
suchErgebnisse.subscribe(melder);
for (Zug zug : zuege) {
EinzelnenZugUntersuchen zugUntersuchen = new EinzelnenZugUntersuchen(stellung, zug, suchErgebnisse);
suchErgebnisse.subscribe(zugUntersuchen);
executorService.execute(zugUntersuchen);
}
} else {
subject.onCompleted();
}
}
示例3: testReplaySubject
import rx.subjects.ReplaySubject; //导入方法依赖的package包/类
public void testReplaySubject() {
ReplaySubject<Integer> replaySubject = ReplaySubject.create();
replaySubject.subscribe(new SubAction("Early: "));
replaySubject.onNext(0);
replaySubject.onNext(1);
replaySubject.subscribe(new SubAction("Later: "));
replaySubject.onNext(2);
}
示例4: testReplaySubjectLimit
import rx.subjects.ReplaySubject; //导入方法依赖的package包/类
public void testReplaySubjectLimit() throws Exception {
ReplaySubject<Integer> replaySubject =/* ReplaySubject.createWithSize(2);*/
ReplaySubject.createWithTime(150, TimeUnit.MICROSECONDS, Schedulers.immediate());
replaySubject.onNext(0);
Thread.sleep(100);
replaySubject.onNext(1);
Thread.sleep(100);
replaySubject.onNext(2);
replaySubject.subscribe(new SubAction("Later: "));
replaySubject.onNext(3);
}