2017-09-20 2 views
0

나는 유동성 목록이 두 개 있는데이 두 가지를 결합하여 일부 기능을 적용하고 유동성 목록을 얻을 수있다. 초기 유동성 목록은 DB 의 데이터를 나타내며 생각이 바뀌면 결합 목록이 변경 될 수있다. 입력이 변경됩니다. 일단 zip이 제대로 작동하면 zip은 올바른 접근 방식이 아니므로 변경 사항을 계속해서 내 보내지는 않습니다. 나는,이 목록을 결합하여 일부 기능을 적용하고 업데이트결합 된 목록에서 2 개의 유동성 목록의 변경 사항을 계속 듣고 싶습니다.

Flowable.zip(shoppingListsRepository.loadCommonArticles(), shoppingListsRepository.loadShoppingListItems(shoppingListId), 
BiFunction<List<CommonArticle>, List<ShoppingListItem>, List<CommonArticle>> { 
commonArticles, shoppingListItems -> 
//apply some filters on these two list and return result 
    items 
}); 


fun loadCommonArticles(): Flowable<List<CommonArticle>> { 
return shoppingListDao.loadCommonArticles() 
} 

fun loadShoppingListItems(shoppingListId: 
Int):Flowable<List<ShoppingListItem>> { 
    return shoppingListDao.loadShoppingListItems(shoppingListId)} 

답변

1

Flowable.combineLatest(stream1, stream2, combineBiFunc)을 고려을 듣고 계속할 수 우편의 대안이 될 수있는 것을 내 질문. stream1이 끝나면 stream2는 stream1의 마지막으로 알려진 목록으로 배출을 생성합니다 (반대의 경우도 마찬가지 임). combineBiFunc에서 업데이트 된 데이터로 수행 할 작업을 결정할 수 있습니다.

+0

고맙습니다. –