https://kotlinlang.org logo
#functional
Title
# functional
t

tschuchort

03/06/2018, 4:24 PM
How would that help? The background service updates latest posts (i.e. at the top of the list) while the pagination loads additional old posts (i.e. at the bottom of the list). I don't even really care about this specific scenario, the app only exists to come up with a scaleable functional architecture that can deal with such problems (like synchronizing parent and child state)
a

Andreas Sinz

03/06/2018, 5:08 PM
The UI should get updated when new Posts arrive, right?
t

tschuchort

03/06/2018, 5:22 PM
when the user hasn't scrolled completely to the top or bottom there will be no visible UI change when the service updates the list, but of course the updated list should be available for the activity
a

Andreas Sinz

03/06/2018, 5:55 PM
then I'd use a producer/consumer architecture. The activities register to get the latest list of posts. When you scroll to the end of the list, you just tell your
PostManager
to retrieve some older posts and you'll get an udpated list through the callback. Same happens when the background service tells the
PostManager
to retrieve the latest posts. This way you have a single object that is responsible for retrieving posts and it can queue the requests as they come in
4 Views