Skip to content

Commit beda9dd

Browse files
authored
Update README.md
1 parent f8d33fb commit beda9dd

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ The library exposes two dependencies to help with coding or decoding your `Codab
121121
@Dependency(\.decode) var decode
122122

123123
struct Point: Codable {
124-
var x: Double
125-
var y: Double
124+
var x: Double
125+
var y: Double
126126
}
127127

128128
let 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

228228
for await isSoundEnabled in $isSoundEnabled {
229-
await isSoundEnabled ? audioEngine.start() : audioEngine.stop()
229+
await isSoundEnabled ? audioEngine.start() : audioEngine.stop()
230230
}
231231
```
232232
### Notifications
233233
This dependency allows exposing `Notification`s as typed `AsyncSequence`s.
234234
```swift
235235
extension 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
```
246246
You 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:
250250
The exposed value is an async sequence of `Float` representing the `batteryLevel`:
251251
```swift
252252
for 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)
265265
bubble up this value into the model:
266266
```swift
267267
HStack { }
268-
.observeEnvironmentAsDependency(\.colorScheme)
269-
.observeEnvironmentAsDependency(\.dismiss)
268+
.observeEnvironmentAsDependency(\.colorScheme)
269+
.observeEnvironmentAsDependency(\.dismiss)
270270
```
271271
In 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
275275
value:
276276
```swift
277277
for 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
297297
If you want to use DependenciesAdditions in a SwiftPM project, it's as simple as adding it to your Package.swift:
298298

299299
dependencies: [
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

Comments
 (0)