2017-03-20 4 views
0

나는 시스템 프로세스를 통해 일을하는 관측 가능 (뜨겁다)을 가지고 있으며, 관찰 할 수있는 이벤트가 onComplete에 도달 할 때까지 간격을 유지하고 싶습니다. (특히, 간격을 취소 할 때 다른 히트의 onComplete) http://reactivex.io/documentation/operators/interval.htmlrxjava 간격을 다른 관측 가능 시간과 결합

가 어떻게이 두 내가 원하는 그 행동을 얻을 결합 할 수 있습니다 :

나는 간격 연산자를 참조?

+0

코드 표시 – shmakova

답변

1

넌 간격 오퍼레이터, takeUntil() 입력으로 Observable 소요 (거부)를 취소하고, 입력 Observable 아이템을 방출 할 때 취소하기 위해 takeUntil() 연산자를 사용할 수있다. 그것은 남아있는 어떤

onComplete()으로 항목을 방출 Observable에 핫 Observable를 변환하고, 우리가 takeUntil() 입력으로 사용할 수 있으며, 이것은 각 Observable 이벤트 Notification 객체를 방출 materialize() 연산자 (사용 가능 onNext(), onError(), onCompleted()), filter()과 결합하여 onCompleted() 이벤트 만 취합니다.

Observable<Notification<Object>> hotOnCompleteObservable = 
      hot.materialize() 
       .filter(notification -> notification.isOnCompleted()); 

Observable interval = ... 
interval.takeUntil(hotOnCompleteObservable); 
관련 문제