rx.Observable.dematerialize()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(159)

本文整理了Java中rx.Observable.dematerialize()方法的一些代码示例,展示了Observable.dematerialize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Observable.dematerialize()方法的具体详情如下:
包路径:rx.Observable
类名称:Observable
方法名:dematerialize

Observable.dematerialize介绍

[英]Returns an Observable that reverses the effect of #materialize by transforming the Notification objects emitted by the source Observable into the items or notifications they represent.

Scheduler: dematerialize does not operate by default on a particular Scheduler.
[中]返回一个Observable,通过将源Observable发出的通知对象转换为它们所表示的项目或通知,来反转#materialize的效果。
调度程序:默认情况下,dematerialize不会在特定调度程序上运行。

代码示例

代码示例来源:origin: jhusain/learnrxjava

public static void subscribe(Observable<String> o) {
    o = o.materialize().flatMap(n -> {
      if (n.isOnError()) {
        if (n.getThrowable() instanceof IllegalStateException) {
          return Observable.just(n);
        } else {
          return Observable.error(n.getThrowable());
        }
      } else {
        return Observable.just(n);
      }
    }).retry().dematerialize();

    o.subscribe(System.out::println, t -> t.printStackTrace());
  }
}

代码示例来源:origin: com.netflix.rxjava/rxjava-core

@Override
  public Observable<?> call(Observable<? extends Notification<?>> ts) {
    return ts.map(new Func1<Notification<?>, Notification<?>>() {
      int num=0;
      
      @Override
      public Notification<?> call(Notification<?> terminalNotification) {
        if(count == 0) {
          return terminalNotification;
        }
        
        num++;
        if(num <= count) {
          return Notification.createOnNext(num);
        } else {
          return terminalNotification;
        }
      }
      
    }).dematerialize();
  }
}

代码示例来源:origin: leeowenowen/rxjava-examples

@Override
 public void run() {
  Observable o1 = Observable.range(1, 3).materialize();
  o1.subscribe(new Action1<Notification<Integer>>() {
   @Override
   public void call(Notification<Integer> integerNotification) {
    log("******");
    log("kind:" + integerNotification.getKind());
    log("value:" + integerNotification.getValue());
   }
  });
  o1.dematerialize().subscribe(new Action1() {
   @Override
   public void call(Object o) {
    log(o.toString());
   }
  });
 }
});

代码示例来源:origin: davidmoten/rxjava-extras

@Override
  public Observable<Out> call() {
    Mutable<State> state = new Mutable<State>(initialState.call());
    return source.materialize()
        // do state transitions and emit notifications
        // use flatMap to emit notification values
        .flatMap(execute(transition, completion, state, backpressureStrategy),
            initialRequest)
        // complete if we encounter an unsubscribed sentinel
        .takeWhile(NOT_UNSUBSCRIBED)
        // flatten notifications to a stream which will enable
        // early termination from the state machine if desired
        .dematerialize();
  }
});

代码示例来源:origin: com.github.davidmoten/rxjava-extras

@Override
  public Observable<Out> call() {
    Mutable<State> state = new Mutable<State>(initialState.call());
    return source.materialize()
        // do state transitions and emit notifications
        // use flatMap to emit notification values
        .flatMap(execute(transition, completion, state, backpressureStrategy),
            initialRequest)
        // complete if we encounter an unsubscribed sentinel
        .takeWhile(NOT_UNSUBSCRIBED)
        // flatten notifications to a stream which will enable
        // early termination from the state machine if desired
        .dematerialize();
  }
});

相关文章

Observable类方法