Hi all 👋 — I’m trying to build a synchroniser with Jetpack’s WorkManager for sync’ing records created locally/saved in Room with a remote server, when the internet connection is available. Room represents my “unsyncronised” records as a
Flow<List<LocalRecord>>
, instead of a
List<LocalRecord>
, and if I try to
collect
on the flow it blocks the worker.
Is this a good idea? If so, how do I retrieve the most up-to-date list of unsync’d `LocalRecord`’s from the flow, without blocking the worker? I’ve tried
collectLatest
and
last
, both of which don’t behave as expected.
If this isn’t a good idea, would it be better to spawn one worker for each record, at the risk of potentially overloading my server if a large number (200+) of records need syncing? I’ve gone through the nowinandroid implementation, and it’s doing some particularly fruity stuff with a
DelegatingWorker
I don’t really understand 😵💫