Closed ijwhelan closed 1 year ago
@helios175 Just pushed some changes, I ended up leaving out the Pair.toSync()
for now in favor of some changes to UpdateWork
to make it clearer that diffing work (a.k.a asyncWork
) isn't always async. Now UpdateWork
has work
and notifications
. If UpdateWork.isSynchronous
is true
, we execute work
and notifications
synchronously, otherwise we go into the coroutines logic.
I think this ends up being a little simpler and more concise than taking the Pair.toSync()
route.
populateMode: UpdateMode
andreplaceMode: UpdateMode
toUpdate
so that we can specify whether to calculate and dispatch updates to the adapter on the UI thread or in the background via Coroutines.populateMode
controls which strategy is used when adding items to the adapter for the first time, this is analogous toallowSynchronousUpdates
(which is removed by this PR).UpdateMode.Sync
should generally be used forpopulateMode
but some things depend on the behavior we had before Cycler 0.1.11 so we need the ability to specifyUpdateMode.Async
.replaceMode
controls which strategy is used when replacing the adapter's dataset. Today we always diff the data in the background and then dispatch the updates on the UI thread, incurring a 1-frame penalty even for trivial diffs. This has the advantage of avoiding dropped frames when handling large datasets but for smaller datasets and certain use cases it's not worth paying this 1-frame penalty.