For the context, I'm currently working on introducing async/await in GRDB, and I'm adapting the demo app for async/await. This allows me to use the new async apis in order to achieve classic tasks, and check the library ergonomics from the point of view of an application developer.
This demo app displays a list of players that come from the database. Each time the database changes, the list updates. This is very classic. To this end, the library provides database observation apis. The async version of these apis is an asynchronous sequence of database changes.
Ideally, the list of players appears on screen already populated from the current database content. This means that it is possible to perform a synchronous fetch of the initial list of players at the time the list is "instantiated". This is the single-responsibility principle in action: the list is responsible for its content.
This is very doable (and highly ranked in the list of required feature set) with raw GRDB apis and its convenience Combine publishers: those can deliver the initial value synchronously when database observation starts. This fits the constraints of both UIKit and SwiftUI, and just makes app developers' life so much easier.
The iterator of the async sequence I'm working on can also emit its initial value immediately. But this advantage is lost whenever this async sequence is started from synchronous app code, because the Task that wraps the sequence iteration always starts too late.
Result: I am unable to have my list appear on screen already populated. There is always this "flash of missing content".
If someone has already met this problem with async/await (I don't think this is GRDB-specific at all), how do you solve it?