@@ -121,8 +121,8 @@ The library exposes two dependencies to help with coding or decoding your `Codab
121121@Dependency (\.decode ) var decode
122122
123123struct Point : Codable {
124- var x: Double
125- var y: Double
124+ var x: Double
125+ var y: Double
126126}
127127
128128let point = Point (x : 12 , y : 35 )
@@ -226,21 +226,21 @@ The projected value is an `AsyncStream<Value>` of this user preference's values.
226226@Dependency .AppStorage (" isSoundEnabled" ) var isSoundEnabled: Bool = false
227227
228228for await isSoundEnabled in $isSoundEnabled {
229- await isSoundEnabled ? audioEngine.start () : audioEngine.stop ()
229+ await isSoundEnabled ? audioEngine.start () : audioEngine.stop ()
230230}
231231```
232232### Notifications
233233This dependency allows exposing ` Notification ` s as typed ` AsyncSequence ` s.
234234``` swift
235235extension Notifications {
236- /// A typed `Notification` that publishes the current device's battery level.
237- @MainActor
238- public var batterLevelDidChange: NotificationOf<Float > {
239- .init (UIDevice.batteryLevelDidChangeNotification ) { notification in
240- @Dependency (\.device .batteryLevel ) var level;
241- return level
236+ /// A typed `Notification` that publishes the current device's battery level.
237+ @MainActor
238+ public var batterLevelDidChange: SystemNotificationOf<Float > {
239+ .init (UIDevice.batteryLevelDidChangeNotification ) { notification in
240+ @Dependency (\.device .batteryLevel ) var level;
241+ return level
242+ }
242243 }
243- }
244244}
245245```
246246You can then expose this notification with a dedicated property wrapper:
@@ -250,9 +250,9 @@ You can then expose this notification with a dedicated property wrapper:
250250The exposed value is an async sequence of ` Float ` representing the ` batteryLevel ` :
251251``` swift
252252for await level in batteryLevel {
253- if level < 0.2 {
254- self .isLowPowerModeEnabled = true
255- }
253+ if level < 0.2 {
254+ self .isLowPowerModeEnabled = true
255+ }
256256}
257257```
258258### SwiftUI Environment
@@ -265,8 +265,8 @@ Then, in any `View`, you use the `.observeEnvironmentAsDependency(\.colorScheme)
265265bubble up this value into the model:
266266``` swift
267267HStack { … }
268- .observeEnvironmentAsDependency (\.colorScheme )
269- .observeEnvironmentAsDependency (\.dismiss )
268+ .observeEnvironmentAsDependency (\.colorScheme )
269+ .observeEnvironmentAsDependency (\.dismiss )
270270```
271271In the example above, ` self.colorScheme ` is a ` ColorScheme? ` , and ` self.dismissAction ` is a
272272` DismissAction? ` . Both are optional because they're conditioned by the existence of the ` View ` , and
@@ -275,7 +275,7 @@ You can observe their value through the projected value which is an `AsyncSequen
275275value:
276276``` swift
277277for await colorScheme in self .$colorScheme.compactMap{ $0 }.dropFirst () {
278- self .logger .info (" ColorScheme did change: \( colorScheme ) " )
278+ self .logger .info (" ColorScheme did change: \( colorScheme ) " )
279279}
280280```
281281### Core Data (WIP)
@@ -297,7 +297,7 @@ https://github.com/tgrapperon/swift-dependencies-additions
297297If you want to use DependenciesAdditions in a SwiftPM project, it's as simple as adding it to your Package.swift:
298298
299299dependencies: [
300- .package(url: "https://github.com/tgrapperon/swift-dependencies-additions ", from: "0.1.0")
300+ .package(url: "https://github.com/tgrapperon/swift-dependencies-additions ", from: "0.1.0")
301301]
302302
303303## License
0 commit comments