我正在尝试在Android应用程序中实现rxJava,我正试图绕过这个。这是我想要满足的场景:
理想情况下,如果步骤2中的调用包含响应,并且未完成,则可以继续运行,直到该作业在后端完成为止。但我在这里采取了一些步骤,并将解决下一步。
更新时间:2015-10-21 这是我到目前为止的地方。我可能会被清理干净。
public Observable<Program> recordedProgram( int chanId, DateTime startTime ) {
final DvrDataStore dvrDataStore = this.dvrDataStoreFactory.create( chanId, startTime );
final ContentDataStore contentDataStore = this.contentDataStoreFactory.createMasterBackendDataStore();
Observable<ProgramEntity> programEntity = dvrDataStore.recordedProgramEntityDetails( chanId, startTime );
Observable<List<LiveStreamInfoEntity>> liveStreamInfoEntity = programEntity
.flatMap(recordedProgramEntity -> contentDataStore.liveStreamInfoEntityList(recordedProgramEntity.getFileName()));
Observable<ProgramEntity> recordedProgramEntity = Observable.zip(programEntity, liveStreamInfoEntity, new Func2<ProgramEntity, List<LiveStreamInfoEntity>, ProgramEntity>() {
@Override
public ProgramEntity call(ProgramEntity programEntity, List<LiveStreamInfoEntity> liveStreamInfoEntityList) {
if (null != liveStreamInfoEntityList && !liveStreamInfoEntityList.isEmpty()) {
programEntity.setLiveStreamInfoEntity(liveStreamInfoEntityList.get( 0 ) );
}
return programEntity;
}
});
return recordedProgramEntity.map(recordedProgram ->
this.programEntityDataMapper.transform(recordedProgram));
}
答案 0 :(得分:0)
.firstObservable.flatmap( ... ) //will have access to first result
.filter( ... ) //will filter out the ones that dont fit your condition)
.map( ... ) //will have access to second result)
.subscribe()