Skip to content
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

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

Open
jverkoey opened this issue Aug 1, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@jverkoey
Copy link
Collaborator

jverkoey commented Aug 1, 2024

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

Rather than have to write something like this:

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:

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

Will require learning how to create a Swift macro.

@jverkoey jverkoey added the enhancement New feature or request label Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant