Skip to content

How to use with a derived request? #14

Answered by groue
mickeyl asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @mickeyl,

I know a technique, shown in one of the GRDB demo apps: https://github.com/groue/GRDB.swift/blob/v5.22.0/Documentation/DemoApps/GRDBCombineDemo/GRDBCombineDemo/Views/AppView.swift#L18

In your app, this should give:

struct VehicleDetailsView: View {
    @ObservedObject var vehicle: Vehicle
    @Query<AllScansForVehicle> var scans: [VehicleScan]

    init(vehicle: Vehicle) {
        self.vehicle = vehicle
        _scans = Query(AllScansForVehicle(vehicle), in: \.dbQueue)
    }
}

This technique can be extended to all other property wrappers that need a custom initialization!

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mickeyl
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