Skip to content

Add AppDelegate entry point example to prepareDependencies documentation #316

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

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions Sources/Dependencies/WithDependencies.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,44 @@ import Foundation

/// Prepares global dependencies for the lifetime of your application.
///
/// > 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.
/// 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.
///
/// For example, in a SwiftUI entry point:
///
/// ```swift
/// @main
/// struct EntryPoint: App {
/// init() {
/// prepareDependencies {
/// $0.defaultDatabase = try! DatabaseQueue(/* ... */)
/// }
/// }
///
/// // ...
/// }
/// ```
///
/// For those that use AppDelegate in UIKit as an entry point:
///
/// ```swift
/// @main
/// class AppDelegate: UIResponder, UIApplicationDelegate {
/// func application(
/// _ application: UIApplication,
/// didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
/// ) -> Bool {
/// prepareDependencies {
/// $0.defaultDatabase = 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