You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's say I have a chat API. It has two functions:
suspend fun getAllMessagesOfConversations(conversationId: Int): List<Message>
Is a one-shot function that fetches all chat messages of a conversation from the network
fun incomingMessagesOfConversation(conversationId: Int): Flow<Message>
Is a function that returns a never-ending flow of incoming messages from the network
Now I want to abstract this and put it behind a Store, with a Source of Truth and in-memory etc. all the good stuff. I want a Flow<List<Message>> that represents all the messages of conversation, updated when a new incoming message was added. What would be the way to implement this?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Let's say I have a chat API. It has two functions:
suspend fun getAllMessagesOfConversations(conversationId: Int): List<Message>
fun incomingMessagesOfConversation(conversationId: Int): Flow<Message>
Now I want to abstract this and put it behind a Store, with a Source of Truth and in-memory etc. all the good stuff. I want a
Flow<List<Message>>
that represents all the messages of conversation, updated when a new incoming message was added.What would be the way to implement this?
This is my implementation suggestion:
However, does this mean that it will refetch the entire conversation, everytime I'm streaming with StoreRequest.cached()?
Beta Was this translation helpful? Give feedback.
All reactions