Skip to content

Commit

Permalink
Add AppDelegate entry point example to prepareDependencies documentat…
Browse files Browse the repository at this point in the history
…ion (#316)

* Add AppDelegate entry point example to prepareDependencies documentation

* Update WithDependencies.swift

---------

Co-authored-by: Stephen Celis <[email protected]>
  • Loading branch information
acosmicflamingo and stephencelis authored Dec 19, 2024
1 parent c81cb3d commit 890b70f
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion Sources/Dependencies/WithDependencies.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,40 @@ import Foundation
///
/// > Important: A dependency key can be prepared at most a single time, and _must_ be prepared
/// > before it has been accessed. Call `prepareDependencies` as early as possible in your
/// > application.
/// > application, for example in your SwiftUI entry point:
/// >
/// > ```swift
/// > @main
/// > struct MyApp: App {
/// > init() {
/// > prepareDependencies {
/// > $0.defaultDatabase = try! DatabaseQueue(/* ... */)
/// > }
/// > }
/// >
/// > // ...
/// > }
/// > ```
/// >
/// > Or your app delegate:
/// >
/// > ```swift
/// > @main
/// > class AppDelegate: UIResponder, UIApplicationDelegate {
/// > func application(
/// > _ application: UIApplication,
/// > didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
/// > ) -> Bool {
/// > prepareDependencies {
/// > $0.defaultDatabase = try! DatabaseQueue(/* ... */)
/// > }
/// > // Override point for customization after application launch.
/// > return true
/// > }
/// >
/// > // ...
/// > }
/// > ```
///
/// - Parameter updateValues: A closure for updating the current dependency values for the
/// lifetime of your application.
Expand Down

0 comments on commit 890b70f

Please sign in to comment.