当前位置: 首页>>代码示例>>Java>>正文


Java ReplaySubject.subscribe方法代码示例

本文整理汇总了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);
}
 
开发者ID:ArturVasilov,项目名称:RxSamplesPractice,代码行数:19,代码来源:Samples.java

示例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();
    }
}
 
开发者ID:DokChess,项目名称:dokchess,代码行数:20,代码来源:MinimaxParalleleSuche.java

示例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);
}
 
开发者ID:yeungeek,项目名称:Android-Gradle-Samples,代码行数:9,代码来源:SubjectTest.java

示例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);
}
 
开发者ID:yeungeek,项目名称:Android-Gradle-Samples,代码行数:12,代码来源:SubjectTest.java


注:本文中的rx.subjects.ReplaySubject.subscribe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。