Skip to content

Async db manager initializer and GRDBQuery #1668

Closed Answered by groue
Jason-Abbott asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @Jason-Abbott,

Is there something that prevents your app from waiting for the database to be migrated before registering the DatabaseContext?

Here is a quick and dirty sample code:

import GRDB
import GRDBQuery

struct LoaderView: View {
    // Initially nil, then not nil when the database is ready
    @State var databaseContext: DatabaseContext?
    
    var body: some View {
        Group {
            if let databaseContext {
                MyView().databaseContext(databaseContext)
            } else {
                ProgressView()
            }
        }
        .task {
            do {
                let dbQueue = try DatabaseQueue()
                try await Task.sleep(for: .s…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Jason-Abbott
Comment options

You must be logged in to vote
1 reply
@groue
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants