ClutchEngineering / ClutchEngineering/slipstream

Add an @Entry macro for easier creation of custom Environment properties

Open
#11 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Swift
Stars
74
Forks
3
PR merge metrics
No merged PRs in 30d

Description

Apple's documentation on the macro: https://developer.apple.com/documentation/swiftui/entry()

Rather than have to write something like this:

```swift
struct PathEnvironmentKey: EnvironmentKey {
static let defaultValue: String = "/"
}

extension EnvironmentValues {
var path: String {
get { self[PathEnvironmentKey.self] }
set { self[PathEnvironmentKey.self] = newValue }
}
}
```

We'd be able to simply do this instead:

```swift
extension EnvironmentValues {
@Entry var path: String = "/"
}
```

Will require learning [how to create a Swift macro](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/macros/).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.