Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
emorydunn committed Jan 27, 2025
1 parent ba73529 commit 4f77bf4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Examples/counter/Sources/counter/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import StreamDeck

extension GlobalSettings {

/// A macro to define the `GlobalSettingsKey` and property used for the key path.
/// A macro to define the `GlobalSettingsKey` and property used for the key path.
@Entry var count = 42

}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ The value can be read and updated from inside an action callback.

#### Macros

Starting in Swift 5.9 two new macros will be available to make declaring environmental values and global settings easier. The macro handles generating both the struct and variable for the key path. The key specified in the macro is used as the key of the setting.
Additionally, instead of manually declaring the keys, you can use the `@Entry` macro. The macro handles generating both the struct and variable for the key path. By default the name is auto-generated based on the property name, but a custom key can be provided.

```swift
extension EnvironmentValues {
#environmentKey("count", defaultValue: 0, ofType: Int.self)
@Entry var count = 42
}

extension GlobalSettings {
#globalSetting("count", defaultValue: 0, ofType: Int.self)
@Entry("CountDracula") var theCount = 42
}
```

Expand Down

0 comments on commit 4f77bf4

Please sign in to comment.