Ankur Prakash
Ankur Prakash

Reputation: 1527

RxSwift Combining heterogeneous observables

I have two objects Chat and messages both in Realm database. I am fetching from db and getting two observables. Message object have chatId through which I can get chat object. chats() - gives Observable<[Chat> messages() - gives Observable<[Messages>

The problem is when I use map function on messages(), I get chatId, now I need chat array to filter the chatId and get chat object.

How can I do that? Can I combine both observables and get emitted both array in single closure. If yes, then how?

Upvotes: 1

Views: 106

Answers (1)

Daniel T.
Daniel T.

Reputation: 33967

Depending on the context, you want to use either combineLatest or withLatestFrom.

I don't quite understand the context because you say you have an Observable<[Message]>, but you are getting a single chatID from that array. I would expect you to get an array of chat IDs.

Upvotes: 1

Related Questions