We don't want to use the mainScope.launch { calculateNotifications ; then update } path if the updates are synchronous (for instance, when only extra item is updated, or when going from empty to not-empty).
This PR changes:
Update.generateDataChangesLambdas is not suspend anymore. It won't just produce a list of notifications for the UI thread, but an UpdateWork comprising async work and notifications.
Recycler.update will receive that and decide to do the sync path (no async work) or the coroutine path (async work).
As both paths need to assign the new recycler data, notify onReady and assign the adapter that is encapsulated in applyNotifications and called from both places.
The async path still checks that currentUpdate is not changed, and call onCancelled if it changed (some other call to update invalidated us).
We don't want to use the
mainScope.launch { calculateNotifications ; then update }
path if the updates are synchronous (for instance, when only extra item is updated, or when going from empty to not-empty).This PR changes:
Update.generateDataChangesLambdas
is notsuspend
anymore. It won't just produce a list of notifications for the UI thread, but anUpdateWork
comprising async work and notifications.Recycler.update
will receive that and decide to do the sync path (no async work) or the coroutine path (async work).onReady
and assign theadapter
that is encapsulated inapplyNotifications
and called from both places.currentUpdate
is not changed, and callonCancelled
if it changed (some other call toupdate
invalidated us).