Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convenience @Query initializers for Void DatabaseContext #41

Merged
merged 10 commits into from
Mar 25, 2023

Conversation

groue
Copy link
Owner

@groue groue commented Mar 24, 2023

This pull request defines a few convenience @Query initializers that avoid specifying an environment key path when the Queryable request uses Void as a DatabaseContext (debugging or testing request).

For example, given this request:

struct PlayersRequest: Queryable {
    static var defaultValue: [Player] { [] }

    // PlayersRequest feeds from nothing (Void)
    func publisher(in _: Void) -> AnyPublisher<[Player], Error> {
        ...
    }
}

One can just write:

struct PlayerList: View {
    @Query(PlayersRequest()) // <- no explicit key path
    private var players: [Player]

    var body: some View {
        List(players) { player in ... }
    }
}

Also in this PR: moved long documentations into DocC extension files.

@groue groue added the enhancement New feature or request label Mar 24, 2023
@groue
Copy link
Owner Author

groue commented Mar 24, 2023

Lol I just went against my own advice by easing the dependency on SwiftUI 😅 #40 (comment)

  • remove the EnvironmentValues convenience!

@groue groue changed the title Convenience @Query initializers for Void and EnvironmentValues contexts Convenience @Query initializers for Void DatabaseContext Mar 25, 2023
@groue groue merged commit 66832b7 into main Mar 25, 2023
@groue groue deleted the convenience-query-initializers branch March 25, 2023 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant